From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23753 invoked by alias); 20 Apr 2018 12:54:29 -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: 42694 Received: (qmail 21207 invoked by uid 1010); 20 Apr 2018 12:54:29 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi0-f50.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.218.50):SA:0(-1.4/5.0):. Processed in 3.192072 secs); 20 Apr 2018 12:54:29 -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.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS, T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: ethersoft@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=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ONhfZEoE51PPrEwVs+WKRbME+mFSmaGR9hVu/PbWry4=; b=qz8rL72OYfe6z/FWn5v0xJnFG8i7UV4oX3a02IRWYBqxzNUwbv+NOSTv6oniaK3Hz0 tKOEmQ7hLEeGsiHhfcwonU6+XQf1OviyVdMpqHHxYC/tZWI9HQV2xbuBQHbsyCgIIR+v 1d5PkHzdKetKmvH0Jt1xysc5xPGrlJEw17EsIvHCiTD7GetIkZKFKnzHl9o4HI31BAfc 8TfsWJV2irMnb9UqfS2Eat3zJgYKq87IyFSDBfVjNkrGBKgKyQBIxGcBsx8ka8GeM5+A CxPqISmFYkleMbvnqPcZmgMvCFVLY80rpqQ1UCZx/oGj2MyWA5PWTvVZ6if/E/umItAE NJ1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ONhfZEoE51PPrEwVs+WKRbME+mFSmaGR9hVu/PbWry4=; b=H8W9XMdnik+oGoGBsiroHnKtmiR/ZbY7oz2pmC2e/W6giFWc7PfYRvHnNDFYUrfwWl Ukfb/EccEH0iMzOb6SesE9IWmla6jSF8yuB5COP2oL2A/8F5iywjzxKfTq1prIaF/TjL 3tV0odLewJiHVpXaafllGRsaPGdh9Eqhz/xskW3XvK8Gb4sq350p4BFHvqzHKVFx0hvw Li6hRNPwikNKYQa1duDsxz7MYaW9LwLTotnn4Tb04aHiEKsKX3NvbJHgeQi3vFIM84Jp w6sG+vEbHiOpEvFLOH5TqHbHHaWMi6ZLvTIBMrxXEygM+JXeQZaBehgAEXfs3y0rUjHE PM9g== X-Gm-Message-State: ALQs6tAfRQOE14dTRUUoq4iQvYsofjPJvY0F4fCvjBvEIZUdbzDDyVVD Aaljbqm2p5P8LeXkG8tuSrQfH6zdc4Rmerc9Rsc= X-Google-Smtp-Source: AIpwx4/i76l3YnEgl2CITtjnhS3DGlvwcSjS6K5EqvnepPZbDKSENdegQlJb+4pMTaLynpvy+LClzs+UmdUWKZJA36c= X-Received: by 2002:aca:4146:: with SMTP id o67-v6mr3444493oia.172.1524228862477; Fri, 20 Apr 2018 05:54:22 -0700 (PDT) MIME-Version: 1.0 Sender: ethersoft@gmail.com In-Reply-To: <20180420110110.599f9cb6@camnpupstephen.cam.scsc.local> References: <180323221959.ZM27569@torch.brasslantern.com> <20180324080514.txxyrb3qiztu4pqt@gmail.com> <180324150945.ZM32251@torch.brasslantern.com> <20180410124545.13fccd5d@camnpupstephen.cam.scsc.local> <20180410145926.64c4f671@camnpupstephen.cam.scsc.local> <180411151025.ZM19332@torch.brasslantern.com> <20180412172342.52df6b10@camnpupstephen.cam.scsc.local> <20180415162326.GA12549@chaz.gmail.com> <20180415185804.GB12549@chaz.gmail.com> <180416223910.ZM32002@torch.brasslantern.com> <20180417101947.5fd347df@camnpupstephen.cam.scsc.local> <180417090926.ZM2456@torch.brasslantern.com> <20180417173558.769503bd@camnpupstephen.cam.scsc.local> <180417105243.ZM2929@torch.brasslantern.com> <20180419104039.7b86ed2b@camnpupstephen.cam.scsc.local> <20180420102839.073d539b@camnpupstephen.cam.scsc.local> <20180420110110.599f9cb6@camnpupstephen.cam.scsc.local> From: Vin Shelton Date: Fri, 20 Apr 2018 08:54:21 -0400 X-Google-Sender-Auth: tZ1VSjGQeS2sA3qXVKGikkA3Yx4 Message-ID: Subject: Re: Forking earlier for background code To: Peter Stephenson Cc: "Zsh Hackers' List" Content-Type: multipart/alternative; boundary="000000000000e78e19056a472f72" --000000000000e78e19056a472f72 Content-Type: text/plain; charset="UTF-8" I really think 5.5.2 should go out with only 5.5.1 + the signals.c change first. My $.02. - Vin On Fri, Apr 20, 2018 at 6:01 AM, Peter Stephenson wrote: > (Sorry about multiple messages, but I'm sure you're fascinated...) > > On Fri, 20 Apr 2018 10:28:39 +0100 > Peter Stephenson wrote: > > It may well be possible to expand the logic to track down other cases > > where we know we can know we're going to need to fork, so can do so > > early to get fewer side effects (and slightly optimise the main > > shell). > >... > > So I think if "last1" is zero and "output" is non-zero we might be > > able to fork early, perhaps? > > If you want to play along at home with step 1 here, try the following. > > As far as I can see, we don't need to take special account of "exec" > here. For the pipeline to work we always need to fork even if the > command has the "exec" keyword in front (same true of "&", in fact). > > > diff --git a/Src/exec.c b/Src/exec.c > index 1b622d5..768e3ef 100644 > --- a/Src/exec.c > +++ b/Src/exec.c > @@ -3146,10 +3146,11 @@ execcmd_exec(Estate state, Execcmd_params eparams, > esprefork = (magic_assign || > (isset(MAGICEQUALSUBST) && type != WC_TYPESET)) ? > PREFORK_TYPESET : 0; > - if (how & Z_ASYNC) { > + if ((how & Z_ASYNC) || (output && !last1)) { > /* > - * If running in the background, we don't need any of > - * the rest of this functino to affect the state in the > + * If running in the background, or not the last command in a > + * pipeline and not already forked, we don't need any of > + * the rest of this function to affect the state in the > * main shell, so fork immediately. > * > * In other cases we may need to process the command line > > pws > --000000000000e78e19056a472f72--