From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11805 invoked by alias); 29 Sep 2014 08:45:57 -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: 33273 Received: (qmail 24158 invoked from network); 29 Sep 2014 08:45:54 -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 X-AuditID: cbfec7f4-b7f156d0000063c7-2c-54291c3d3e5a Date: Mon, 29 Sep 2014 09:45:51 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: SIGPIPE (Re: ZSH history not saved anymore) Message-id: <20140929094551.5d0256f6@pwslap01u.europe.root.pri> In-reply-to: <140928131627.ZM4749@torch.brasslantern.com> References: <87mw9qdp7s.fsf@thinkpad-t440p.tsdh.org> <20140924200710.2f764272@pws-pc.ntlworld.com> <8738bg2n1v.fsf@thinkpad-t440p.tsdh.org> <140926000448.ZM30835@torch.brasslantern.com> <878ul6lrw9.fsf@thinkpad-t440p.tsdh.org> <87y4t66td0.fsf@thinkpad-t440p.tsdh.org> <871tqxqyil.fsf@thinkpad-t440p.tsdh.org> <140927105301.ZM31550@torch.brasslantern.com> <20140927214035.7af22023@pws-pc.ntlworld.com> <140927165554.ZM32155@torch.brasslantern.com> <140928110438.ZM27132@torch.brasslantern.com> <20140928191850.61c28815@pws-pc.ntlworld.com> <140928131627.ZM4749@torch.brasslantern.com> 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+NgFupjluLIzCtJLcpLzFFi42I5/e/4ZV1bGc0Qg0PLJS0ONj9kcmD0WHXw A1MAYxSXTUpqTmZZapG+XQJXxqYfHSwFT7kqVt1+zdbA+Je9i5GTQ0LARGJyw0dmCFtM4sK9 9WxdjFwcQgJLGSWWPWljhXCWM0k8PPqaCaSKRUBV4suLR2AdbAKGElM3zWYEsUUExCXOrj3P AmILC1hIzN44FyzOK2AvsbFjNxuIzSlgKfHy1UwWiKFvWSW6ds8HG8QvoC9x9e8nJogz7CVm XjkD1Swo8WPyPbChzAJaEpu3NbFC2PISm9e8ZZ7AKDALSdksJGWzkJQtYGRexSiaWppcUJyU nmuoV5yYW1yal66XnJ+7iREShl92MC4+ZnWIUYCDUYmHl2OFRogQa2JZcWXuIUYJDmYlEV41 ac0QId6UxMqq1KL8+KLSnNTiQ4xMHJxSDYyRSmwTmiImeK1b8fLFP+ekafV3H67aHJ7d9vMp 642OlMNK33UbfNYscFvBxWqo9Wbl+lNBO3QkbCVqGQPelcaVlJV/eWR22+v12+2PjN9L1lb1 XSlpOXDD2DWA33SyoGdrRYrAeuabx95/63I46Dt9qdK16LaDyaftAriFov++5xGIOcq05a4S S3FGoqEWc1FxIgBwGx9mIQIAAA== On Sun, 28 Sep 2014 13:16:27 -0700 Bart Schaefer wrote: > On Sep 28, 7:18pm, Peter Stephenson wrote: > } > } So in the first case I presume we're exiting (silently) on SIGPIPE. That > } should be just a question of checking if SIGPIPE is trapped and if it isn't > } setting the handler to the default in entersubsh(). There's some partial > } prior art for this. > > It gets a little stranger - this is again before the patch: > > torch% TRAPPIPE() { : } > torch% (sleep 5; echo hello; print -u2 $sysparams[pid] continued after PIPE) | > (exit) > TRAPPIPE: write error: broken pipe > echo: write error: broken pipe > zsh: write error: broken pipe > 3579 continued after PIPE > > > Why did TRAPPIPE() receive a SIGPIPE? And then: I think we're looking at this in execcmd() or similar chunks. /* It's a builtin */ if (forked) closem(FDT_INTERNAL); lastval = execbuiltin(args, (Builtin) hn); fflush(stdout); if (save[1] == -2) { if (ferror(stdout)) { zwarn("write error: %e", errno); clearerr(stdout); } } else clearerr(stdout); so it doesn't necessarily mean there's a signal, just that there's a broken pipe. Maybe the fflush() is enough to trigger setting errno again if it failed to write the first time? pws