From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5960 invoked by alias); 15 Feb 2015 14:03:32 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 34547 Received: (qmail 2570 invoked from network); 15 Feb 2015 14:03:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=IUBcuvERNpD20M4Gicb5ZuFGvNladMWI4nzC1eEZb+Q=; b=k+NGWsbeacxXQRDn65o40TyuzxQr9Q9CWTd/3MGmfY+T+sVYR5KL2KA/p8IlnWCGhq svzpXpFMOSZG2mGCdnxTxO4xJGt0JT4uE4j0L7TftlqypXkCQUveEinNbc1GCWKeJuCq dzU55foxGZ3u5x33a43kbl4v/mMD/XwS2iBrpC+TCIQOjZrl3VC1NOcZrrbFPQSKqD4p DeLH2sfQPpOYc/7YPY6PlbrIvCDkst9pe9Ehu7CtGjAflbAR/zTm71Q8Y0fPZ+gK1R5N Fl6FB68PW4vOGhrU/SeuxqnMTy3w5QguFLm1A2xM08YlZfw54HJqq2+zX9ADHHFh9L9O 1sGg== X-Received: by 10.202.102.158 with SMTP id m30mr11990960oik.22.1424009005927; Sun, 15 Feb 2015 06:03:25 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <150214105834.ZM4462@torch.brasslantern.com> References: <20150211101130.2ac4d9b5@pwslap01u.europe.root.pri> <150211081345.ZM17542@torch.brasslantern.com> <20150213103919.GD1848@tarsus.local2> <150214105834.ZM4462@torch.brasslantern.com> From: Soares Chen Date: Sun, 15 Feb 2015 22:03:05 +0800 Message-ID: Subject: Re: Zsh scripts leave defunct processes when running under docker exec To: Bart Schaefer Cc: zsh-workers@zsh.org Content-Type: text/plain; charset=UTF-8 On Sun, Feb 15, 2015 at 2:58 AM, Bart Schaefer 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