From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 63393fa1 for ; Mon, 29 Jul 2019 23:09:06 +0000 (UTC) Received: (qmail 21358 invoked by alias); 29 Jul 2019 23:08:57 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24107 Received: (qmail 26196 invoked by uid 1010); 29 Jul 2019 23:08:57 -0000 X-Qmail-Scanner-Diagnostics: from joooj.vinc17.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25524. spamassassin: 3.4.2. Clear:RC:0(155.133.131.76):SA:0(-1.9/5.0):. Processed in 2.090962 secs); 29 Jul 2019 23:08:57 -0000 X-Envelope-From: vincent@vinc17.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at vinc17.net does not designate permitted sender hosts) Date: Tue, 30 Jul 2019 01:08:17 +0200 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: kill the LHS command of a pipe once the RHS command terminates Message-ID: <20190729230817.GA13849@zira.vinc17.org> Mail-Followup-To: zsh-users@zsh.org References: <20190628110430.GA13790__36317.6205357135$1561719956$gmane$org@zira.vinc17.org> <20190628184134.btrejxp7jyoo6wz6@chaz.gmail.com> <20190629012433.GA23526@zira.vinc17.org> <20190629153055.kb444goqcmpfblac@chaz.gmail.com> <20190706234919.GA14626@zira.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20190706234919.GA14626@zira.vinc17.org> X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/1.12.1+33 (6a74e24e) vl-117499 (2019-06-23) On 2019-07-07 01:49:19 +0200, Vincent Lefevre wrote: > Actually I suppose that Ctrl-C kills the subshell, and the pager > as a consequence. And if I use the following, > > page-and-kill() (trap '' INT; "$@" | { trap - INT; less; kill 0; }) > > the "kill 0" no longer kills the command. This can be seen with: > > (trap '' INT; { echo foo; sleep 10; } | { trap - INT; less; kill 0; }) > > after typing Ctrl-C in "less", then q to quit. I've noticed that > dash and mksh have the same issue, but neither bash, nor ksh93. Actually a better example should be: (trap '' INT; sleep 10 | { trap - INT; less; echo foo; kill 0; }) If I wait for 10 seconds, then type 'q' in less, I get: zira% (trap '' INT; sleep 10 | { trap - INT; less; echo foo; kill 0; }) foo zsh: terminated ( trap '' INT; sleep 10 | { trap - INT; less; echo foo; kill 0; }; ) zira% But if I type Ctrl-C then 'q' in less, the "sleep 10" is still running, and I get after the 10 seconds: zira% (trap '' INT; sleep 10 | { trap - INT; less; echo foo; kill 0; }) zira% i.e. no "foo" output and no "zsh: killed" line, i.e. after the Ctrl-C in less, zsh terminated the right-hand side. I suppose that this is due to WUE, and both bash and ksh93 do not have this issue as they implement WCE. It seems that putting "trap - INT; less;" in a subshell does the work. However, I get annoying messages: zira% (trap '' INT; svn log | { (trap - INT; less;); kill 0; }) svn: E000004: Write error: Interrupted system call zsh: terminated ( trap '' INT; svn log | { ( trap - INT; less; ); kill 0; }; ) With "kill -9", this is a bit better: zira% (trap '' INT; svn log | { (trap - INT; less;); kill -9 0; }) zsh: killed ( trap '' INT; svn log | { ( trap - INT; less; ); kill -9 0; }; ) But I would like to get rid of this message. -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)