From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21949 invoked by alias); 27 Sep 2014 17:52:54 -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: 33257 Received: (qmail 20104 invoked from network); 27 Sep 2014 17:52:39 -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: <140927105301.ZM31550@torch.brasslantern.com> Date: Sat, 27 Sep 2014 10:53:01 -0700 In-reply-to: <871tqxqyil.fsf@thinkpad-t440p.tsdh.org> Comments: In reply to Tassilo Horn "Re: ZSH history not saved anymore" (Sep 27, 10:05am) 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> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: SIGPIPE (Re: ZSH history not saved anymore) MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 27, 10:05am, Tassilo Horn wrote: } Subject: Re: ZSH history not saved anymore } } > Obviously you can work around the problem by telling zsh to trap that } > signal: } > } > TRAPPIPE() { } > exit } > } } } Yes, that works. So I'll keep that in my ~/.zshrc for the time being. I'm a bit hesitant to change this after all these years, but perhaps an interactive shell should exit on SIGPIPE if the terminal is not still open? I'm probably missing something having to do with subshells receiving the PIPE signal. There are regrettably many code paths covering all the ways an interactive shell might fork. diff --git a/Src/init.c b/Src/init.c index 40f46a8..6d005dc 100644 --- a/Src/init.c +++ b/Src/init.c @@ -1134,6 +1134,7 @@ init_signals(void) winch_block(); /* See utils.c:preprompt() */ #endif if (interact) { + install_handler(SIGPIPE); install_handler(SIGALRM); signal_ignore(SIGTERM); } diff --git a/Src/signals.c b/Src/signals.c index cb2b581..094b4b0 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -594,6 +594,17 @@ zhandler(int sig) wait_for_processes(); break; + case SIGPIPE: + if (!handletrap(SIGPIPE)) { + if (!interact) + _exit(SIGPIPE); + else if (!isatty(SHTTY)) { + stopmsg = 1; + zexit(SIGPIPE, 1); + } + } + break; + case SIGHUP: if (!handletrap(SIGHUP)) { stopmsg = 1;