From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8322 invoked by alias); 21 Dec 2013 03:42:38 -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: 32171 Received: (qmail 23171 invoked from network); 21 Dec 2013 03:42:22 -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 From: Bart Schaefer Message-id: <131220194223.ZM29152@torch.brasslantern.com> Date: Fri, 20 Dec 2013 19:42:23 -0800 In-reply-to: <131220181950.ZM15385@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: Fwd (potential regression in 5.0.3): Bug#732726: zsh function freeze" (Dec 20, 6:19pm) References: <20131220192435.GE27889@sym.noone.org> <131220122701.ZM15525@torch.brasslantern.com> <20131220235149.GA21721@xvii.vinc17.org> <20131220235955.GB21721@xvii.vinc17.org> <20131221001235.GC21721@xvii.vinc17.org> <131220181950.ZM15385@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Vincent Lefevre , zsh-workers@zsh.org Subject: Re: Fwd (potential regression in 5.0.3): Bug#732726: zsh function freeze MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Dec 20, 6:19pm, Bart Schaefer wrote: } } + * 31549: Src/exec,c, Src/zsh.h: replace ad-hoc subsh_close file } + descriptor for pipes with new addfilelist() job-based mechanism. Yep, that's the one. I compiled commit 709dbbbda82efde2020d9d67a19687c101b91570 and was able to reproduce the problem. The immediately preceding commit 39ab9952e8255cb99e9c0abcc8bbec43158a55d7 does not show the bug. Non-interactive shells also do not show the bug, which may be why "make check" didn't flag anything. The problem seems to be with this hunk specifically: @@ -1744,8 +1742,6 @@ execpline2(Estate state, wordcode pcode, execpline2(state, *state->pc++, how, pipes[0], output, last1); list_pipe = old_list_pipe; cmdpop(); - zclose(pipes[0]); - subsh_close = -1; } } The problem is that pipes[0] isn't always added to the list of files for the job; sometimes it really does need to be closed there. diff --git a/Src/exec.c b/Src/exec.c index dccdc2b..4480033 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1691,6 +1691,7 @@ execpline2(Estate state, wordcode pcode, execcmd(state, input, output, how, last1 ? 1 : 2); else { int old_list_pipe = list_pipe; + int subsh_close = -1; Wordcode next = state->pc + (*state->pc), pc; wordcode code; @@ -1738,6 +1739,7 @@ execpline2(Estate state, wordcode pcode, } else { /* otherwise just do the pipeline normally. */ addfilelist(NULL, pipes[0]); + subsh_close = pipes[0]; execcmd(state, input, pipes[1], how, 0); } zclose(pipes[1]); @@ -1750,6 +1752,8 @@ execpline2(Estate state, wordcode pcode, execpline2(state, *state->pc++, how, pipes[0], output, last1); list_pipe = old_list_pipe; cmdpop(); + if (subsh_close != pipes[0]) + zclose(pipes[0]); } }