zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: 5.0.8 regression when waiting for suspended jobs
Date: Wed, 12 Aug 2015 10:43:51 +0100	[thread overview]
Message-ID: <20150812104351.65a4cbea@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <150811165655.ZM31504@torch.brasslantern.com>

On Tue, 11 Aug 2015 16:56:55 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Jul 31,  8:56am, Bart Schaefer wrote:
> I still only suspect what changed to make 5.0.8 different from 5.0.7 in
> this regard, but here's what's going on:

> - "wait $!" -
> } zsh-5.0.7
> }  - "wait $!" blocks (looping on repeated wait3() nonzero)
> } zsh-5.0.8
> }  - "wait $!" loops but also printing status every time
> 
> bin_fg() calls waitforpid() which discovers the job is stopped and goes
> into a loop calling kill(pid, SIGCONT) to try to get the job to run
> again.  In the 5.0.8 case, each time this happens the job briefly wakes
> up, gets stopped with SIGTTIN, thus causes another SIGCHLD to go to the
> parent zsh, which then prints the "suspended" message and loops right
> back to kill(pid, SIGCONT) again.
> 
> All of this is exactly the same as in 5.0.7 except that because of the
> SIGCONT change in workers/35032 we notice the stopped -> continued ->
> stopped again status change and therefore print the new status even
> though it's actually the same as the last time we printed the status,
> because we skipped printing the "continued" status.  Or so I surmise.

So you might have thought the right thing to do was note it had been
stopped immediately, possibly warn the user, and not try to continue it
again without further user action?  Is that easy?  Can we pin down
"immediately" well enough?  Clearly there's a race in the real world
where the programme could get SIGTTIN at any time, but in the general
case (i.e. where a background process got SIGTTIN when the foreground
was doing something irrelevant) you clearly *don't* want it to continue
every time.

In that case the difference between 5.0.7 and 5.0.8 becomes
basically moot (it's different but in a sane fashion).

Do we even understand what the loop with SIGCONT is doing for us?  Under
what circumstances would this help?  Some (other sort of) race where
something else (what?  Not zsh and not the process that's suspended)
takes a while to get going, so the SIGCONT only succeeds after a few
attempts?

> - wait %1" -
> 
> bin_fg() calls zwaitjob() which does NOT do kill(pid, SIGCONT) instead
> simply blocking forever waiting for a SIGCHLD that will never arrive.

Hmm... I can't think of a good reason from the user point of view why
this should behave differently.  It just seems confusing.  It's
certainly not documented as a zsh feature, is it?

> - "wait" -
> 
> bin_fg() goes into a loop calling zwaitjob() on every entry in the job
> table; i.e., identical to "wait %1" repeated for every job number.

In which case I think the same reaction arises.

pws


  reply	other threads:[~2015-08-12  9:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-30 14:32 Christian Neukirchen
2015-07-30 19:39 ` Bart Schaefer
2015-07-31  8:30   ` Christian Neukirchen
2015-07-31 15:56     ` Bart Schaefer
2015-07-31 17:28       ` Christian Neukirchen
2015-07-31 17:41         ` Bart Schaefer
2015-08-11 23:56       ` Bart Schaefer
2015-08-12  9:43         ` Peter Stephenson [this message]
2015-08-12 14:58           ` Bart Schaefer
2015-08-12 16:09             ` Peter Stephenson
2015-08-12 17:31               ` Bart Schaefer
2015-08-15  1:56                 ` Bart Schaefer
2015-08-16 17:37                   ` Peter Stephenson
2015-08-16 21:49                     ` 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=20150812104351.65a4cbea@pwslap01u.europe.root.pri \
    --to=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).