From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8806 invoked by alias); 28 Aug 2013 16:00:19 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17950 Received: (qmail 26271 invoked from network); 28 Aug 2013 16:00:13 -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=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <130828085952.ZM24071@torch.brasslantern.com> Date: Wed, 28 Aug 2013 08:59:52 -0700 In-reply-to: <20130828144752.7986a138@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: Implicit killing of subprocesses" (Aug 28, 2:47pm) References: <521DF308.4040106@necoro.eu> <20130828142651.4c930ba4@pwslap01u.europe.root.pri> <521DFD56.3040904@necoro.eu> <20130828144752.7986a138@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: Implicit killing of subprocesses MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Aug 28, 2:47pm, Peter Stephenson wrote: } } In this case, the NOHUP option is irrelevant --- because you don't have } job control (it's determined by the MONITOR option which is unset in } non-interactive shells), the shell doesn't send SIGHUP to processes on } exiting (without job control it doesn't have much idea of which } processes would need it). So I think you get the effect you want. I think the effect Rene wants is that the coproc job DOES get killed when the script exits? Which won't happen with MONITOR turned off. A coproc is not very different than a backgroup job started with "... &" except for where its standard input and output are connected. However, you can "setopt monitor" in the script. If you do this before starting the coproc, zsh SIGHUPs the job before exiting. You get the usual warnings: coprocscript:7: you have running jobs. coprocscript:7: warning: 1 jobs SIGHUPed If the setopt comes after the coproc, the first warning is printed, but the SIGUP is not sent. If the job started with coproc can be relied upon to exit when it gets EOF on its standard input, then instead of setopt monitor you can end it explicitly with: TRAPEXIT() { coproc exit } The "coproc exit" is not magic, it's just an idiom for closing all the existing coproc descriptors in the parent shell by starting a new no-op coproc in place of whichever one is already running. It is best if the TRAPEXIT is not created until after the coproc job is started.