From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1565 invoked by alias); 11 Feb 2015 06:53:19 -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: 34505 Received: (qmail 24527 invoked from network); 11 Feb 2015 06:53:18 -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.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=HkCy2vbtBUwgE97zuhK/cI6GkV549rgQwHb/4ldQazY=; b=cHeI4IpMQNAjXGsFOKyZvCy/FKamDpIC6+3/8oUUSIv5sEkb+Bkbew3VRdOrcmd2xI mHfQ70/L5usYXs+Xc86nkBFjFCDs9iwmLIYv+vEPYb7YhTFX5YArJdlNA2D9vd+TXTn7 0rKmeTPc0gV5VxzWa6uvoudau5uiEs2A4KX9033DqfFeXoz8DMfhGZKoUk9Jk//qwSrc qG2gGD+7FCMM/FkAgwMd1Xj1+xkPwrMI1PiywhWlxjhxiJ3koYdZhM3nN4KM4pJit9Mn n1bF06If52s6fJZZtohoF+Gq+AFARX2de6p11sXl641YzY6yY4LIvzecMdX3Kuca2lqp LvKQ== X-Gm-Message-State: ALoCoQnKTAZve2j3zzUlqxh0V8402o87QOgPgZOzEOUaobBk3MsJrqsKMQ5wkBU/9MThOyNcNqrT MIME-Version: 1.0 X-Received: by 10.180.206.98 with SMTP id ln2mr16348227wic.94.1423637593467; Tue, 10 Feb 2015 22:53:13 -0800 (PST) In-Reply-To: References: Date: Tue, 10 Feb 2015 22:53:13 -0800 Message-ID: Subject: Re: Zsh scripts leave defunct processes when running under docker exec From: Bart Schaefer To: Soares Chen Cc: "zsh-workers@zsh.org" Content-Type: multipart/alternative; boundary=001a11c381ce0c4702050eca7557 --001a11c381ce0c4702050eca7557 Content-Type: text/plain; charset=UTF-8 On Tuesday, February 10, 2015, Soares Chen wrote: > 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. > (Someone more knowledgeable may be able to correct any misconceptions I have about docker.) I'm not exactly a docker expert, but my understanding is that docker incorporates (is built on?) the relatively recent Linux feature of "PID namespaces". Under a PID namespace, the first process started is assigned PID 1and is expected to behave like the "init" process in a traditional Unix/Linux system, and be the ultimate manager of all the other processes spawned within the namespace. Zsh is not designed to assume that role. In particular, when processing a script, it will optimize process handling and perform an implicit "exec" of the final command in the script, so that it need not hang around waiting for that process to exit, assuming that it's own parent will reap it. In a "docker exec" there is no parent to do so. --001a11c381ce0c4702050eca7557--