From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9945 invoked by alias); 18 Jul 2013 11:32:21 -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: 31536 Received: (qmail 9827 invoked from network); 18 Jul 2013 11:32:15 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) X-AuditID: cbfec7f4-b7fd76d0000035e1-10-51e7d23b1437 Date: Thu, 18 Jul 2013 12:32:10 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: bug with eval, proc-subst and pipes Message-id: <20130718123210.054f1ea1@pwslap01u.europe.root.pri> In-reply-to: <20130718102227.527429bd@pwslap01u.europe.root.pri> References: <20130715133525.GA7694@chaz.gmail.com> <130715100624.ZM14123@torch.brasslantern.com> <20130716215540.22d88a27@pws-pc.ntlworld.com> <130717000027.ZM15643@torch.brasslantern.com> <20130717201733.2c0b029b@pws-pc.ntlworld.com> <20130718095741.3f54725f@pwslap01u.europe.root.pri> <20130718102227.527429bd@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmluLIzCtJLcpLzFFi42I5/e/4VV3rS88DDe6strY42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGXuaggteC1W8WnmQpYFxM18XIweHhICJxNx+qy5GTiBTTOLC vfVsXYxcHEICSxkldnx7xwzhLGeSmDzxBhtIA4uAqsSs/XkgDWwChhJTN81mBLFFBMQlzq49 zwJiCwsYSCxvOQkW5xWwl3i55w4ziM0p4CCxYeI7mAXMEieut4M18AvoS1z9+4kJ4gp7iZlX zkA1C0r8mHwPrIZZQEti87YmVghbXmLzmrfMExgFZiEpm4WkbBaSsgWMzKsYRVNLkwuKk9Jz DfWKE3OLS/PS9ZLzczcxQgLwyw7GxcesDjEKcDAq8fAa8j8PFGJNLCuuzD3EKMHBrCTC+20f UIg3JbGyKrUoP76oNCe1+BAjEwenVANjvTTPhdmCRrXzTnK0FKf9qavfPlld1TLS56/y9stM TRyv/hZ5syYEbu83/rtsV99vmY6MHaq/5OfnZpxz3/vvTm++8cQDac+Sp4o/UHT8mrm85InG 357vDBw9lkGb/nb/c/1VNkf6mbDCw2kGHx/O/SohWVDoKrmISfWdVFjRDs5m/UjjR1eUWIoz Eg21mIuKEwGFgrbmHgIAAA== On Thu, 18 Jul 2013 10:22:27 +0100 Peter Stephenson wrote: > On Thu, 18 Jul 2013 09:57:41 +0100 > Peter Stephenson wrote: > > Will it be good enough to go through all process substitution output > > file descriptors for a job when we enter zwaitjob() and close them? I > > think at that point nothing more can write from the main shell process, > > and subprocesses in any case have to manage their own copies of the file > > descriptor. > > Thinking about it, it would presumably be safe just to close all > temporary file descriptors at that point, including input, since there's > nothing in the job that can read input now, either. So there's no need > to distinguish input and output. We keep the existing close logic as a > backup. I don't think it's safe to delete temporary files yet, however, > since unlike the file descriptors, which are local to the process, those > can be accessed directly by subprocesses still running. Apparently working (except for the fact it doesn't fix Stephane's original problem, don't know if we're any further forward with that). However, I'll wait in case Bart can see something I missed. diff --git a/Src/jobs.c b/Src/jobs.c index a1955bb..432f0f5 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -1368,6 +1368,30 @@ zwaitjob(int job, int wait_cmd) jn->stat |= STAT_LOCKED; if (jn->stat & STAT_CHANGED) printjob(jn, !!isset(LONGLISTJOBS), 1); + if (jn->filelist) { + /* + * The main shell is finished with any file descriptors used + * for process substitution associated with this job: close + * them to indicate to listeners there's no more input. + * + * Note we can't safely delete temporary files yet as these + * are directly visible to other processes. However, + * we can't deadlock on the fact that those still exist, so + * that's not a problem. + */ + LinkNode node = firstnode(jn->filelist); + while (node) { + Jobfile jf = (Jobfile)getdata(node); + if (jf->is_fd) { + LinkNode next = nextnode(node); + (void)remnode(jn->filelist, node); + zclose(jf->u.fd); + node = next; + } else { + incnode(node); + } + } + } while (!errflag && jn->stat && !(jn->stat & STAT_DONE) && !(interact && (jn->stat & STAT_STOPPED))) { pws