From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12968 invoked by alias); 25 Mar 2018 07:01:01 -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: List-Unsubscribe: X-Seq: 42527 Received: (qmail 3100 invoked by uid 1010); 25 Mar 2018 07:01:01 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm0-f51.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.82.51):SA:0(-1.9/5.0):. Processed in 1.047054 secs); 25 Mar 2018 07:01:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Ozst2gReyzVf8PVBV8FqvIa8TM7Zkoj2U9iAL41tUSM=; b=Vsd9q1pHNx37b9fcszDSXLcStuy/IhAx/CQp8jto7sEIiDNFhy1FnmI9+koj+ULRA8 2OZWg2u7cxXIm9D+YTnLr5dsQMHEU1WTs1v8Kp9eJskc3aWDrpAeoZ3lq2uQNSfCoSep OT/lcEwinsnC/y9AtE9im5Xg4kQaJ658uYffrCFAytQIDZFVOtuEu8XZ4/G57y2wum74 7fcLNpuhk2+7vA/ZOW0SnmC6NfRIU9IGsRD5up2h9cJizldHwa+jZnMqA9dwRV3W2XPM duUvnnJqidqbk2OPHnQT3/EA2TnKyKqa4hcjn1lBYruwpdfQL8UdhisLWVgMMiGi+UT7 H37w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=Ozst2gReyzVf8PVBV8FqvIa8TM7Zkoj2U9iAL41tUSM=; b=IJ8B2cZHFcJdfBxeh2dz7eaAa8LNTG6vQ0LkQ9msQWCC987w69SkZzwIqBeniHHQz7 ebVzf7NGiWCr3Mn5k5dBD5Yk1yCQb1oiwdHEhPcOGu8tNrB8AlE6+WX5zf4o4bSpj+nf U87YoRR41P5r47EdtyQe1s49nHB9ayBnJjBfGWhLxeEN8+W2nbXDvJlgQ2XPLD0Hy6Bd iQ8SmcZb/91AjIZuUDxW65DDXsPNiKEs+P/7Kdmxvr0iLf2aSTmD1/Bap5UFRDkUnbXo OlSlHRiAiPUfgudN0n9azFEnqLjukwWRQt76bN8Lel9BjC6LxpvwVPoNWhxbv/9oZXpT KnyQ== X-Gm-Message-State: AElRT7Fr1ws2PFt9IYLUJtwdfqNCfGI0+Ud08nsorrFCWoc2HzFW0Ohn 1/PkIsomYs2hNxD1yB90Cbq8GA== X-Google-Smtp-Source: AG47ELvQ9i2AIAaAuWKr13LH6LYVVC840W/3ZqNBlsRer8zIf8GwnI7A4zXXVDyXzuXxVYqS8TpOCA== X-Received: by 10.80.195.202 with SMTP id i10mr21119491edf.232.1521961255934; Sun, 25 Mar 2018 00:00:55 -0700 (PDT) Date: Sun, 25 Mar 2018 08:00:53 +0100 From: Stephane Chazelas To: Bart Schaefer Cc: Zsh hackers list Subject: Re: "echo | ps -j $(:) | cat | cat | cat" runs components in different process groups Message-ID: <20180325070053.GB5782@chaz.gmail.com> Mail-Followup-To: Bart Schaefer , Zsh hackers list References: <20180323161612.GB4857@chaz.gmail.com> <180323163614.ZM10192@torch.brasslantern.com> <180323221959.ZM27569@torch.brasslantern.com> <20180324080514.txxyrb3qiztu4pqt@gmail.com> <20180324173406.GA18604@chaz.gmail.com> <180324152357.ZM32580@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <180324152357.ZM32580@torch.brasslantern.com> User-Agent: Mutt/1.5.24 (2015-08-30) 2018-03-24 15:23:57 -0700, Bart Schaefer: > On Mar 24, 5:34pm, Stephane Chazelas wrote: > } Subject: Re: "echo | ps -j $(:) | cat | cat | cat" runs components in diff > } > } Bart explained that it was because zsh uses the first spawned > } process (here to run a builtin) for the process group, makes > } other processes, that first process has already returned and has > } been waited for so zsh can't make the other processes join the > } foreground process group. > } > } I think here, zsh should not wait for that process until all the > } processes in the jobs have been started and joined the process > } group if that's what from a now-zombie process. > > That's going to require a lot of mucking about, because currently > all process reaping is done in signal handlers. The shell only > explicitly waits for the rightmost process in a pipeline. The > SIGCHLD can't be blocked because then the exit of $(cat) in the > second pipe step could not be captured, so the handler *will* be > called when "echo" exits. [...] Note that the fact that in a | b $(c) | D The $(c) is done by the top-level process, that c is a child of the top-level shell process as opposed to the process that will eventually execute b is unique to zsh (and is complicating things here). That also causes some surprises like in $ set +o multios $ (sleep 1; echo A >&2) | echo B $(sleep 2) >&2 | echo C A B C ("echo C" not started before "sleep 2" finishes) or: Or (though some would find the zsh behaviour less surprising): $ n=1; echo $((++n)) >&2 | echo $((++n)) >&2 | echo $n 2 3 3 (2, 2, 1 in any order in other shells) See also: $ set +o multios $ echo A >&2 | echo $((+)) | echo B A zsh: bad math expression: operand expected at end of string [1] done echo A >&2 "echo A" run but not "echo B" and message about a background job returning. $ sleep 10 | echo $((+)) | echo B zsh: bad math expression: operand expected at end of string $ jobs [1] running sleep 10 $ fg fg: no current job # fg %1 works $ [1] done sleep 10 IIRC, that was discussed not so long ago on the austin-group mailing list (which process should perform the expansions in pipelines) though I didn't follow the discussion. -- Stephane