zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: 5.0.8 regression when waiting for suspended jobs
Date: Wed, 12 Aug 2015 10:31:00 -0700	[thread overview]
Message-ID: <150812103100.ZM13899@torch.brasslantern.com> (raw)
In-Reply-To: <20150812170904.2c0e78de@pwslap01u.europe.root.pri>

On Aug 12,  5:09pm, Peter Stephenson wrote:
} Subject: Re: 5.0.8 regression when waiting for suspended jobs
}
} On Wed, 12 Aug 2015 07:58:58 -0700
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} > We could special-case the SIGTT* signals, we obviously know (from the
} > status that's printed) which signal stopped the job.
} 
} That kind of makes sense, since very few if any(?) other signals have
} this retry-and-fail-again-immediately behaviour.  Many other IO-related
} signals are permanent failures, anyway.

This is a bit ugly, suggestions welcome.  In the "is a child but has no
job table entry" case, this won't SIGCONT the child where previous it
would have, so there's that.

diff --git a/Src/jobs.c b/Src/jobs.c
index ed647b8..ef2bbf0 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1379,16 +1379,26 @@ int
 waitforpid(pid_t pid, int wait_cmd)
 {
     int first = 1, q = queue_signal_level();
+    Process pn;
 
     /* child_block() around this loop in case #ifndef WNOHANG */
     dont_queue_signals();
     child_block();		/* unblocked in signal_suspend() */
     queue_traps(wait_cmd);
     while (!errflag && (kill(pid, 0) >= 0 || errno != ESRCH)) {
-	if (first)
-	    first = 0;
-	else
-	    kill(pid, SIGCONT);
+	if (first) {
+	    Job jn;
+	    /* We may be waiting for a pid that is a child
+	     * but does not have a job table entry? */
+	    first = !findproc(pid, &jn, &pn, 0);
+	}
+	else if (!WIFSTOPPED(pn->status) ||
+		 (WSTOPSIG(pn->status) != SIGTTIN &&
+		  WSTOPSIG(pn->status) != SIGTTOU))
+	    kill(pid, SIGCONT);		/* Harmless if not stopped */
+	/*
+	  else break;  This is bash behavior, just give up when stopped
+	*/
 
 	last_signal = -1;
 	signal_suspend(SIGCHLD, wait_cmd);


  reply	other threads:[~2015-08-12 17:31 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
2015-08-12 14:58           ` Bart Schaefer
2015-08-12 16:09             ` Peter Stephenson
2015-08-12 17:31               ` Bart Schaefer [this message]
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=150812103100.ZM13899@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).