Open joshma opened 8 years ago
Hmm, that's not the behavior I see.
ckuehl@sodium:~$ cat test.sh
#!/bin/sh
yes > /dev/null &
yes > /dev/null
ckuehl@sodium:~$ pgrep yes
ckuehl@sodium:~$ dumb-init ./test.sh
then, in another terminal
ckuehl@sodium:~$ pgrep yes
19179
19180
ckuehl@sodium:~$ pkill dumb-init
ckuehl@sodium:~$ pgrep yes
ckuehl@sodium:~$
ckuehl@sodium:~$ pgrep yes
ckuehl@sodium:~$ dumb-init -c ./test.sh
in another terminal:
ckuehl@sodium:~$ pgrep yes
19241
19242
ckuehl@sodium:~$ pkill dumb-init
ckuehl@sodium:~$ pgrep yes
19241
19242
I'm running my tests outside of a Docker container, though. Are you running inside one? The container will exit when PID 1 (probably dumb-init) exits, and dumb-init exits as soon as bash exits. Since you're not in setsid mode, it won't send SIGTERM to the yes processes. But they'll be gone anyway since the entire container is about to exit.
We usually find setsid mode more useful outside of containers (e.g. being able to signal a server and its worker processes, even if it doesn't forward signals to children normally).
Oh derp, I'm running inside a container.
But they'll be gone anyway since the entire container is about to exit.
Could you help point me to documentation on what happens to child processes when a container exits? I was under the impression that it just sends SIGTERM + SIGKILL to PID 1, does it do anything else that causes it to differ from running it outside a container?
Why can't you have a PID 1 (dumb-init) doing setsid
, i.e.: running in session mode. Is this an OS limitation or design decision ?
I'm trying to understand when running dumb-init under a session (i.e. not using
--single-child
) is useful, and I'm having a hard time reproducing the problem case. Here's a script I'm running that just runsyes
as both background and foreground:And then I'm running
dumb-init -c -- /script.sh
:When I run
kill 13014
, thesh
process quits, and allyes
processes quit as well. It's immediate, so this isn't the "TERM then wait 10s before KILL" behavior. This looks like good behavior, even though I'm using the-c
flag. Am I incorrectly reproducing this?