Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Zsh scripts leave defunct processes when running under docker exec



On Sun, Feb 15, 2015 at 2:58 AM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> I don't know if Chet is reading this and wants to chime in, but I suspect
> bash is not expecting to take over the PID=1 role of init, either.

I'm not sure how bash work differently from zsh, but my example script
works fine if changing the first line to run using bash.

I have talked to people at Docker. From my understanding, Linux has a
feature called subreaper that can take over the role of init and
become the parent of orphaned descendant processes. In this case  on
top of having different PID namespaces, `docker exec` is spawning a
process called nsenter to act as the subreaper. It is responsible to
reap defunct processes by handling SIGCHLD. With it being the
subreaper, all orphaned/defunct processes are captured by nsenter
instead of propogating to the actual init process inside the
container.

So current Docker didn't handle SIGCHLD properly and therefore causing
all orphaned processes to become defunct. It is probably not a problem
of zsh, just that its way of implicitly exec and orphaning child
processes in the final command causing this bug to become obvious in
Docker.

Thank you Bart for explaining and now I know a little better on how
zsh, Docker, and Linux works!

Soares



Messages sorted by: Reverse Date, Date, Thread, Author