What happens to a process when its parent sshd process terminates?
If I run a shell on host1 and execute ssh host2
some-command
, then I close the terminal window (or otherwise terminate the process on ssh
host1
) as if on host2
The sshd
process terminated quickly. But…… What happens to some-command
? Depending on what command it is, it sometimes terminates, but sometimes it doesn’t. What signal does some-command
receive? What file descriptors (if any) were manipulated and how?
Solution
It does not receive any signal. If they are not redirected in some way, the three standard IO streams are pipes in and out of the ssh process, so reading from stdin will return EOF, while writes to stdout or stderr will fail and raise SIGPIPE. If some-command does not perform I/O on the standard stream, there is no reason for it to terminate prematurely.