zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: Another bug when suspending pipelines
Date: Fri, 16 Sep 2016 21:52:41 +0100	[thread overview]
Message-ID: <20160916215241.0b1531d7@ntlworld.com> (raw)
In-Reply-To: <160916113801.ZM11473@torch.brasslantern.com>

On Fri, 16 Sep 2016 11:38:01 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> * The parent responds by stopping all the other jobs in the current
>   pipeline.  It forks the brace expression into a new process and
>   stops that one as well (or maybe that one stops itself, I don't
>   recall the exact sequence of events here).

This is where the problem was.  The forked shell is supposed to stop
itself, but because it was in the same process group it was also being
stopped by the parent shell.

> The parent has to manage all three of these jobs, because it can't
> hand off the already-forked "sleep 7" to the newly-forked brace job.
> It has to arrange that the brace job can be sent a SIGCONT on "fg"
> but not actually do anything until the "sleep 7" has finished; I
> believe that's handled by the "synch" pipes and hidden reads; in any
> case, it works.

The parent shell "simply" waits for the non-shell processes that were
forked directly from the parent shell on the right of the pipeline and
restarts the forked shell to run the rest (which may, of course, include
other external processes) when those have finished.  The synch just
ensures syncronisation at the start, though I'm not sure what good it's
doing.

> On "fg" the parent:
> * makes "sleep 7" the tty group leader again
> * sends SIGCONT everywhere

except the forked subshell

> * and waits for "sleep 7" to exit.
?
> If I'm correct about the synch pipe, the tail of the brace expression
> is blocked waiting to read that.

No, it's stopped itself waiting to be resstarted.

> * makes the tail of the brace expression into a process group which
>   becomes the tty leader, and
> * writes a byte on the synch pipe to wake it up.

This all happened in one go when the shell was forked.  (Its process
group is the subject matter here.)

pws


  reply	other threads:[~2016-09-16 20:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20160916123306eucas1p1f4349b727ebdfb64b4947c9d210457e1@eucas1p1.samsung.com>
2016-09-16 12:33 ` Peter Stephenson
     [not found]   ` <CGME20160916164752eucas1p1add32b4825e126def7b3317c07731342@eucas1p1.samsung.com>
2016-09-16 16:47     ` Peter Stephenson
2016-09-16 18:38   ` Bart Schaefer
2016-09-16 20:52     ` Peter Stephenson [this message]
2016-09-16 22:25       ` Bart Schaefer

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=20160916215241.0b1531d7@ntlworld.com \
    --to=p.w.stephenson@ntlworld.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).