From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24621 invoked by alias); 12 Aug 2015 17:31:08 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36133 Received: (qmail 12555 invoked from network); 12 Aug 2015 17:31:07 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=pZVE8poSu7TvJnMjdd4m21mfwbYbUx4uBDEo7biXs9M=; b=LXkpMgZYASRJvEJNa2j/CU53YYdDDoqDr3OvdnlDciCbWQrEyhGzJYuhX8qHstjiVr eSy0hID5MXzG0tI8DBKlQCPlb5ugcAi+GsASGr+7OzC4CRnALaEvGvb91P2o25pJWmjY NssfMER7ASOvUfAzyDmJ7rFoS5Ea6Ag8rENMDpGpK4ovj9rzMtki3YYa5FX8cm2LIwKX 5DuIZEGD2WOYlOlM2xRnsM9NyprZW1kxotBQfGBx6LZ7v/sbmLXLP5oqcDZsXLUq5Jyz aAJ9IFSfrz3WDUgSVkCVvXAKwciUHC1CLXZTVS8ZsyX2RjdUzYNNgyEqN4pXo0tgDIkx KSnA== X-Gm-Message-State: ALoCoQnTghuI7ghOICQ0KIPKUANOwveKBR+q+jUwzCuR1OUHrjmEa5y712yVJwDSN1q8KJRNum5d X-Received: by 10.202.232.67 with SMTP id f64mr30176371oih.63.1439400664346; Wed, 12 Aug 2015 10:31:04 -0700 (PDT) From: Bart Schaefer Message-Id: <150812103100.ZM13899@torch.brasslantern.com> Date: Wed, 12 Aug 2015 10:31:00 -0700 In-Reply-To: <20150812170904.2c0e78de@pwslap01u.europe.root.pri> Comments: In reply to Peter Stephenson "Re: 5.0.8 regression when waiting for suspended jobs" (Aug 12, 5:09pm) References: <87wpxhk970.fsf@gmail.com> <150730123904.ZM11774@torch.brasslantern.com> <87si84k9uf.fsf@gmail.com> <150731085638.ZM15733@torch.brasslantern.com> <150811165655.ZM31504@torch.brasslantern.com> <20150812104351.65a4cbea@pwslap01u.europe.root.pri> <150812075858.ZM32741@torch.brasslantern.com> <20150812170904.2c0e78de@pwslap01u.europe.root.pri> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: 5.0.8 regression when waiting for suspended jobs MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 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);