How to kill ros running in Docker with SSH disconnect, SIGHUP

asked 2020-06-04 21:36:16 -0500

mugetsu gravatar image

I have two machines on the same LAN. One has an SSH server and also runs a Docker container. The other, I use as the client. I use that to SSH to the server machine, and then send a command to the container on that machine:

ssh -X -t user@server_host 'docker exec -it docker_container\
        bash -ci roslaunch foo foo.launch;bash'

Perhaps this is not best practice?

I would like the processes opened here to all be killed when I close the ssh connection. However, it does not seem to detect SIGHUP.

I tried the same commands to a native non-docker machine with the same setup and SIGHUP properly kills everything when I close.

Is this possible or do I have to send a manual docker kill command? I like the simplicity of just closing my SSH windows

edit retag flag offensive close merge delete

Comments

This is not an answer, but: I typically do this:

ssh [other args] '/path/to/workspace/env.sh roslaunch [other roslaunch args]'

no need to source .bashrc (ie: interactive login) and everything will still work with the ROS environment env.sh is part of.

This is essentially what roslaunch does when you start things remotely with the machine element (although it starts nodes directly and doesn't use roslaunch itself).

gvdhoorn gravatar image gvdhoorn  ( 2020-06-05 04:22:29 -0500 )edit

@gvdhoorn thanks for the method, good to know that non-interactive login is possible.

mugetsu gravatar image mugetsu  ( 2020-06-05 17:03:18 -0500 )edit