From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5258 invoked by alias); 11 Feb 2015 04:44:24 -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: 34503 Received: (qmail 4809 invoked from network); 11 Feb 2015 04:44:09 -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:from:date:message-id:subject:to:content-type; bh=NZQH0Vk4te75Yk66Tn5NcImssdl9oQ5HOUvKsvfyTyc=; b=Cq/pbkPArV2Mp1Yyper9QkzbqAcJ2HwQZqK3NppJ2sgjunbdp1pBH2Mw7hp2TXJhOJ ZJM8yCkPXwkMroF0WCWdNJua99Iy1L6esUj4om6sGyF/WNgqFJtGncpmtn5hgTxqZm51 yQw1D5rU7CUTtOPPEqYQMIcuq5KI7OjgbKtZ3/za/dzBBzqAulseAimA1xtZO5nmXuca JlRLBLtZeioRemvANF6lcz5oQo5w4Ul29BMW7vEEuYdq2tJYSR2HY4LJ/MClYCM/U//B xocSbyp57LAHfO1SJtMbDryLehgrtUL5HS69W0JmqW09VfdPO4OfHwkjVEtO15eQDy34 irEA== X-Received: by 10.202.65.8 with SMTP id o8mr17193230oia.113.1423629847215; Tue, 10 Feb 2015 20:44:07 -0800 (PST) MIME-Version: 1.0 From: Soares Chen Date: Wed, 11 Feb 2015 12:43:47 +0800 Message-ID: Subject: Zsh scripts leave defunct processes when running under docker exec To: zsh-workers@zsh.org Content-Type: text/plain; charset=UTF-8 This only happens when the script is running inside a shell spawned by `docker exec`. When running under normal system and under `docker run`, there is no defunct process. This bug is first discovered when I run nvm in docker (https://github.com/creationix/nvm/issues/650). It was then discovered that Docker's nsenter did not properly handle the SIGCHLD signal raised from zsh. (https://github.com/docker/libcontainer/pull/369) Even though it is now been fixed by Docker, I am not sure why zsh would cause this bug in the first place. I have a test script at the end of this post and also share it on https://gist.github.com/soareschen/240e49116c7f2632d179 Steps to reproduce: # terminal 1 docker run -it --rm --name test-zsh ubuntu:latest /bin/bash apt-get install zsh curl curl https://gist.githubusercontent.com/soareschen/240e49116c7f2632d179/raw/0be67acefd8d18fd62bb181998996f9a5772dc64/docker-zsh-test.sh > docker-zsh-test.sh chmod +x docker-zsh-test.sh ./docker-zsh-test.sh ps auxf # no defunct process # terminal 2 docker exec -it test-zsh /bin/zsh ./docker-zsh-test.sh ps auxf # sed and zsh shown as defunct processes #!/bin/zsh # docker-zsh-test.sh if [[ "$(echo "the black cat was chased by the brown dog" | sed -e 's/cat/fox/g' | grep fox)" = "" ]]; then echo "cat" else echo "fox" fi