From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21418 invoked by alias); 24 Mar 2018 05:20:17 -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: 42516 Received: (qmail 13863 invoked by uid 1010); 24 Mar 2018 05:20:17 -0000 X-Qmail-Scanner-Diagnostics: from mail-pf0-f177.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(209.85.192.177):SA:0(-1.9/5.0):. Processed in 10.193103 secs); 24 Mar 2018 05:20:17 -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,RCVD_IN_DNSWL_NONE, SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=txa71rmQRKwZRH5+pSJ+f0nEgKEIct6Nm01PEtdJrsw=; b=VteVo4pT8Wt2yocRqkg/QoWyWN4VE9c56vi5ozfgs0glkdCeD+0n5XVP/yR5qVGvPE vQD10KRU/nS1YiF94XmsXOHPc2PzIXqCMmDxWoxS09wHzwqYn5nMfi6KT1JSRMxjtZD2 9BFX21KIcpkFwzDX3P6+a+BoTzP6TLMbmjHxhbmEqMbtjnJxSMevCKfSL0hBaYCdI7At oP7YqGGdVnY0HRAn7qKB8TPcHrgWuidAIWbRO2waWbvZA4QWowhw+KVwoAmlnP6tzPei Zs65YJlrd4+e1eG4NU0wtr6cNhJTrVpDX+S72z8FDAaGY/HYWN4fgRcCppEO2leKm1Hl v6AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=txa71rmQRKwZRH5+pSJ+f0nEgKEIct6Nm01PEtdJrsw=; b=JQ6Cdgl0FWwG26RkgWnwUHO7es4hD5GgI9WV5pnMsJJKvHUJuVr7fISjZ33cSgmQOQ vsCssmsVoEoCvt+E+PXVn4YarQUpgln1p5LaEXffrOD817+l5KTaTNksbNm/srawBWnW t0uH9EOOfyJsX7Z1BU92LLaVxg4c+6i7dwrFPamYKnDzQtvYMknodL34T7efMqrRnOcC Rsa3GA6cVfN2Jp8OE8oc8u/IWgZ85KB2iiODHnpu0KzGYDFkh6hTV0Wv/uNrZsE1s8Jb 2NmE2jtFlTyQKnqnScibziZkP8f9/Z3WgSLLeKOP6/lik0/ls7VrPgyCZki3yWtKDp3/ LYoQ== X-Gm-Message-State: AElRT7FblRrpc3gufphCega0XrKajKSwOtYJqGJQzczx6cbDeUo/B2Br W4Yi4lDgtvael6p5I1JnjtmCmR6v X-Google-Smtp-Source: AG47ELstUXJuxHt53xruj+1uiIYSI/LmbUqfwDDXDTU7UXPMSzVIb22TydHvwoFrY+0wlLWeOVdccg== X-Received: by 10.98.30.66 with SMTP id e63mr26272768pfe.67.1521868804154; Fri, 23 Mar 2018 22:20:04 -0700 (PDT) From: Bart Schaefer Message-Id: <180323221959.ZM27569@torch.brasslantern.com> Date: Fri, 23 Mar 2018 22:19:59 -0700 In-Reply-To: <180323163614.ZM10192@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: "echo | ps -j $(:) | cat | cat | cat" runs components in different process groups" (Mar 23, 4:36pm) References: <20180323161612.GB4857@chaz.gmail.com> <180323163614.ZM10192@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh hackers list Subject: Re: "echo | ps -j $(:) | cat | cat | cat" runs components in different process groups MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Mar 23, 4:36pm, Bart Schaefer wrote: } } Zsh wants to use "echo" as the group leader because it was the first to } fork, but because $(:) delayed the execution of "ps" the "echo" process } has already exited and cannot be made group leader. As the fallback the } other processes each get made into its own process group. } } So it's a race condition, adding the process substitution just happens } to expose it. It may be this easy? It fixes the specific example in the subject by causing the zsh parent shell to re-assume job leader for all subsequent processes in the pipeline if the current leader is dead. However, I'm concerned that if the first leader is reaped after a few processes in a long pipeline are created, there may still be a new process group asserted for remaining processes. On the other hand I haven't found an example where that occurs, instead I get jobs where the process group ID is the PID of the now-dead leader. It could be I just haven't constructed the right test. In any case "make check" still passes and this appears to be better than the previous situation. diff --git a/Src/exec.c b/Src/exec.c index 35b0bb1..52b0eb4 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3455,6 +3455,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, if (type == WC_SUBSH && !(how & Z_ASYNC)) flags |= ESUB_JOB_CONTROL; filelist = jobtab[thisjob].filelist; + list_pipe_child = list_pipe; entersubsh(flags); close(synch[1]); forked = 1;