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 f70c5370 for ; Fri, 28 Jun 2019 11:39:08 +0000 (UTC) Received: (qmail 14178 invoked by alias); 28 Jun 2019 11:39:00 -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: 23992 Received: (qmail 17536 invoked by uid 1010); 28 Jun 2019 11:39:00 -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/25489. spamassassin: 3.4.2. Clear:RC:0(155.133.131.76):SA:0(-1.9/5.0):. Processed in 1.510238 secs); 28 Jun 2019 11:39:00 -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: Fri, 28 Jun 2019 13:38:25 +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: <20190628113825.GA16372@zira.vinc17.org> Mail-Followup-To: zsh-users@zsh.org References: <20190628110430.GA13790@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: <20190628110430.GA13790@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-06-28 13:04:30 +0200, Vincent Lefevre wrote: > * With a process substitution: > > zira% head -n 1 <(echo foo; sleep 3; echo err >&2) > foo > zira% > > Here I get the shell prompt back immediately, which is good. But > the left-hand-side command is still running, so that it still > consumes resources; moreover, after the 3 seconds, I get > > zira% err > > In practice, one may want to redirect stderr to the pager too (not > always, though); this avoids this second issue, but not the first one, > which is that the left-hand-side command still consumes resources. There's another issue, but that's a bug in "less": If one uses the less -c option (in addition to -f, needed with process substitution), Ctrl-C no longer has any effect: one cannot interrupt the command to go back to the shell. Example: zira% less -fc <(echo foo; sleep 3; echo err >&2) (tested under Debian/unstable). And I've noticed that zsh doesn't react to Ctrl-C either in the following case: zira% { echo foo; sleep 3; echo err >&2 } | { head -n 1 } while Ctrl-C terminates the pipeline as expected with zira% { echo foo; sleep 3; echo err >&2 } | head -n 1 With zira% { echo foo; sleep 3; echo bar; sleep 3; echo err >&2 } | { head -n 2 } I can terminate the pipeline during the first "sleep 3" (i.e. while "head -n 2" is still running), but not during the second "sleep 3" (i.e. once "head -n 2" has terminated). -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)