From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11746 invoked by alias); 27 Oct 2013 20:33:58 -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: 31916 Received: (qmail 3123 invoked from network); 27 Oct 2013 20:33:53 -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,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:date:from:to:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=V27ktciL/Ug0jpEqx6j6UwORRmtJAE8rLz6umf5xytQ=; b=B0B8lshVYFnyFGrf9hXbkxjVVC+CXGg9YxPDVdmq02msJnv/eL9pWldNwfUkLRtg4T tCuRZ/y8xPocHdHlz+/L96R0Pk0T16cy0YJXZQBvJu1XH1T6bWdEpM+4RkhyAoijPQqL UwtuwIBwPyr9vRTQxbycWsIk3SQIrSwhgwXxv8GD5dDPFfzT7NYNvkVN2/5mJ42yFhC3 IxT/z0eFUEt81jBCUyQNDbCATiSDus2zJuYpyIyZsmCkmhYMGoB9XxTUhQsVM9pnLN0E JC1B795UMzE5fyQM/QN/WhFYw/SxC6NEDDZo7avos9lzspOhox8ZIKsqOJEjOHmrSn9i 8CBg== X-Gm-Message-State: ALoCoQngnkY0kzzTzy+66TX0Sy2BjCWEG7jvPikacvCs7wlh3TKJj10x1Dldnanf/F+BJU82d0ML X-Received: by 10.180.219.33 with SMTP id pl1mr6349739wic.49.1382906030704; Sun, 27 Oct 2013 13:33:50 -0700 (PDT) X-ProxyUser-IP: 86.6.157.246 Date: Sun, 27 Oct 2013 20:33:47 +0000 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: Multio deadlock (Re: multios doesn't work with 2>&1) Message-ID: <20131027203347.15be6bc2@pws-pc.ntlworld.com> In-Reply-To: <131027123917.ZM27930@torch.brasslantern.com> References: <20131027145917.GA5509@localhost.localdomain> <131027100137.ZM4100@torch.brasslantern.com> <20131027174645.6934d78d@pws-pc.ntlworld.com> <131027112724.ZM16426@torch.brasslantern.com> <131027123917.ZM27930@torch.brasslantern.com> X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.7; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 27 Oct 2013 12:39:17 -0700 Bart Schaefer wrote: > Does the following look right? It does fix the deadlock, but we might > call close() on an already closed fd, which it appears this is trying > to avoid (maybe so as not to change errno?). > > diff --git a/Src/exec.c b/Src/exec.c > index 99c7eaa..7ac1ad5 100644 > --- a/Src/exec.c > +++ b/Src/exec.c > @@ -3372,7 +3372,7 @@ execcmd(Estate state, int input, int output, int how, int last1) > * hairy. > */ > for (i = 0; i < 10; i++) > - if (fdtable[i] != FDT_UNUSED) > + if (i < 3 || fdtable[i] != FDT_UNUSED) > close(i); > closem(FDT_UNUSED); > if (thisjob != -1) Hmm... why don't we initialise fdtable[0..2] to FDT_INTERNAL at boot? I can see we don't, since from a shell soon after start I get (gdb) p fdtable[0]@11 $6 = "\000\000\000\000\000\000\000\000\000\000\001" (FDT_UNUSED = 0, FDT_INTERNAL = 1). However, I've alsoe looked later and seen all three set to FDT_INTERNAL; not sure where that happens but presumably something to do with redir. Shouldn't we just initialise them properly? We could in principle detect if they're open by attempting to dup() and seeing what fd we get. Not sure if that's worth it, but it might be cleaner. pws