zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: Bug related to stdin/always/jobcontrol
Date: Sun, 25 Sep 2016 16:16:20 +0100	[thread overview]
Message-ID: <20160925161620.035dac1c@ntlworld.com> (raw)
In-Reply-To: <20160922115921.GA3613@fujitsu.shahaf.local2>

On Thu, 22 Sep 2016 11:59:21 +0000
Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> This (39331) broke fg'ing a function for me:
> 
> % print $ZSH_PATCHLEVEL 
> zsh-5.2-dev-1-401-g4e51079
> % f() { $EDITOR } 
> % f
> <press ^Z in the editor>
> zsh: suspended  f
> % fg
> [1]  + continued  f
> zsh: suspended (tty output)  f
> 
> After the 'fg' I get another prompt immediately, instead of being
> returend to $EDITOR.

I think this is a fairly straightforward additional race fix, luckily, at
least to get us to the point where known problems are fixed.

In the cases I was looking at before, the processes associated with the
SUPERJOB already existed, and there was no further opportunity of fixing
up the pgrp for the SUBJOB.  The fact those processes already existed
also determined the pgrp for the SUBJOB, which is what's being set here
that caused the case above to be mishandled.

In this case, there's no process associated with the SUPERJOB yet, but
that's OK: everything gets handled properly when there is one.  I think
the gleader of the SUBJOB doesn't need any further special handling here
(everything seems to work, anyway).  Process handling and SUPERJOB
creation are murkily separate, so I don't think this is (necessarily)
buggy.

There could well be more aspects as I certainly haven't got my mind
round everything --- in particular, I don't know for sure that the fact
the shell has registered processes associated with the superjob is
actually tied to the subjob's pgrp, which is what this test assumes,
just that that appears to be so in the cases I've tried.

pws

diff --git a/Src/exec.c b/Src/exec.c
index d924148..a5086c3 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1703,7 +1703,8 @@ execpline(Estate state, wordcode slcode, int how, int last1)
 			    jobtab[list_pipe_job].stat |= STAT_SUPERJOB;
 			    jn->stat |= STAT_SUBJOB | STAT_NOPRINT;
 			    jn->other = pid;
-			    jn->gleader = jobtab[list_pipe_job].gleader;
+			    if (hasprocs(list_pipe_job))
+				jn->gleader = jobtab[list_pipe_job].gleader;
 			}
 			if ((list_pipe || last1) && hasprocs(list_pipe_job))
 			    killpg(jobtab[list_pipe_job].gleader, SIGSTOP);


      parent reply	other threads:[~2016-09-25 15:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-02 18:39 Christian Neukirchen
2016-09-05 15:04 ` Christian Neukirchen
2016-09-05 15:42 ` Peter Stephenson
     [not found]   ` <CGME20160914173110eucas1p1f0567e319ae439b975b19f4e55676fed@eucas1p1.samsung.com>
2016-09-14 17:31     ` Peter Stephenson
2016-09-14 21:35       ` Peter Stephenson
2016-09-15  3:24         ` Bart Schaefer
2016-09-15  8:27           ` Peter Stephenson
2016-09-15 10:33             ` Peter Stephenson
2016-09-15 17:40               ` Peter Stephenson
2016-09-16  1:08                 ` Bart Schaefer
2016-09-16 12:02                   ` Peter Stephenson
2016-09-22 11:59         ` Daniel Shahaf
2016-09-22 16:38           ` Bart Schaefer
2016-09-23  1:18             ` Bart Schaefer
2016-09-23  6:06               ` Daniel Shahaf
2016-09-25 14:39               ` Peter Stephenson
2016-09-25 22:54                 ` struct job.other (was Re: Bug related to stdin/always/jobcontrol) Bart Schaefer
2016-09-26 11:20                   ` Peter Stephenson
2016-09-26 16:33                     ` Bart Schaefer
2016-09-25 15:16           ` Peter Stephenson [this message]

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=20160925161620.035dac1c@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).