Skip to content

Instantly share code, notes, and snippets.

@knewter
Created May 29, 2013 17:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knewter/5671928 to your computer and use it in GitHub Desktop.
Save knewter/5671928 to your computer and use it in GitHub Desktop.
Can't make second command die when parent shell dies

When I execute the following:

su - deployer -c "ls; sleep 250"

It outputs the ls and then sleeps for a few minutes. If I hit Ctrl+C, I get this output:

Session terminated, terminating shell... ...killed.

But then, this happens and I do not expect it:

root@machine:# ps ax|grep slee
29918 ?        S      0:00 sleep 250

That is, the sleep process is still running, even though its parent process was terminated.

How can I structure this such that the parent process' death also results in this sleep process' death?

This is causing me grief because I have a similar setup, but cannot get my daemontools or upstart scripts to reliably bring the process down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment