zsh-workers
 help / color / mirror / code / Atom feed
From: Vin Shelton <acs@alumni.princeton.edu>
To: Peter Stephenson <p.stephenson@samsung.com>
Cc: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: Forking earlier for background code
Date: Fri, 20 Apr 2018 08:54:21 -0400	[thread overview]
Message-ID: <CACeGjnV3TtANpmjXbTFnqEW5FBTyViPBVz--1eLGhb8dFo4+vw@mail.gmail.com> (raw)
In-Reply-To: <20180420110110.599f9cb6@camnpupstephen.cam.scsc.local>

[-- Attachment #1: Type: text/plain, Size: 1872 bytes --]

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 <p.stephenson@samsung.com>
wrote:

> (Sorry about multiple messages, but I'm sure you're fascinated...)
>
> On Fri, 20 Apr 2018 10:28:39 +0100
> Peter Stephenson <p.stephenson@samsung.com> 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
>

  reply	other threads:[~2018-04-20 12:54 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-23 16:16 "echo | ps -j $(:) | cat | cat | cat" runs components in different process groups Stephane Chazelas
2018-03-23 23:36 ` Bart Schaefer
2018-03-24  5:19   ` Bart Schaefer
2018-03-24  8:05     ` Joey Pabalinas
2018-03-24 17:34       ` Stephane Chazelas
2018-03-24 22:23         ` Bart Schaefer
2018-03-25  7:00           ` Stephane Chazelas
2018-03-25  8:26             ` Stephane Chazelas
2018-03-25  7:48           ` Stephane Chazelas
2018-03-25 18:09             ` Stephane Chazelas
2018-03-27 10:17         ` Stephane Chazelas
2018-03-24 22:09       ` Bart Schaefer
2018-04-10 11:45         ` Peter Stephenson
2018-04-10 13:59           ` Peter Stephenson
2018-04-11 22:10             ` Bart Schaefer
2018-04-12 16:23               ` Peter Stephenson
2018-04-15 16:23                 ` Stephane Chazelas
2018-04-15 17:38                   ` Bart Schaefer
2018-04-15 18:58                     ` Stephane Chazelas
2018-04-17  5:39                       ` Bart Schaefer
2018-04-17  9:19                         ` Peter Stephenson
2018-04-17 16:09                           ` Bart Schaefer
2018-04-17 16:27                             ` Bart Schaefer
2018-04-17 16:35                             ` Peter Stephenson
2018-04-17 17:52                               ` Bart Schaefer
2018-04-19  9:40                                 ` Peter Stephenson
2018-04-20  9:28                                   ` Forking earlier for background code Peter Stephenson
2018-04-20 10:01                                     ` Peter Stephenson
2018-04-20 12:54                                       ` Vin Shelton [this message]
     [not found]                                         ` <CGME20180420132008eucas1p1c297624e870975cd892c74254970faab@eucas1p1.samsung.com>
2018-04-20 13:20                                           ` Peter Stephenson
2018-04-20 16:01                                             ` Vin Shelton
2018-04-23  8:29                                     ` Peter Stephenson
2018-05-01  9:23                                       ` Peter Stephenson
     [not found]                                   ` <F3A62E38-24E2-4A62-8E19-F54C9B81E9E5@kba.biglobe.ne.jp>
2018-04-23 13:52                                     ` "echo | ps -j $(:) | cat | cat | cat" runs components in different process groups Peter Stephenson
2018-04-23 14:03                                       ` Peter Stephenson
     [not found]                                         ` <CGME20180423140859eucas1p2591bf1422614209979d4890383268c37@eucas1p2.samsung.com>
2018-04-23 14:08                                           ` Peter Stephenson
2018-04-23 15:29                                         ` Jun T.
2018-04-18  6:29                           ` Stephane Chazelas
2018-04-18 16:33                             ` Bart Schaefer
2018-04-10  9:53   ` Peter Stephenson
2018-03-25  7:38 ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACeGjnV3TtANpmjXbTFnqEW5FBTyViPBVz--1eLGhb8dFo4+vw@mail.gmail.com \
    --to=acs@alumni.princeton.edu \
    --cc=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).