Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [BUG?] "wait <PID>" sometimes confused with multiple childs
- X-seq: zsh-workers 42453
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: "Antoine C." <acalando@xxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: [BUG?] "wait <PID>" sometimes confused with multiple childs
- Date: Mon, 12 Mar 2018 14:19:46 +0000
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180312141953euoutp017f1ed20591a0e671acfda37817cb2af9~bMhu_XUPC2479924799euoutp01J
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1520864393; bh=JS6pUR+d9pJNNPRya30eKwMIp3k7zYOfaMA4ECrvvCo=; h=Date:From:To:Subject:In-reply-to:References:From; b=dYnJi67qw4rcu5thfWs7zkm7i048SvH2A3AJS078DaolrLkISSiLi9/wNQkJt1fbo cdchhw5Pwp0T3N7bLoTXRbh9ugd6TLwYe+BXatE3KYYkCzt+a/araWMzaY2m2PzRGN D8LKhNryn8PwDWIOorPZ4fd2cIFy82ozMlGDfgGM=
- In-reply-to: <1328064061.551458859.1520861039419.JavaMail.root@zimbra62-e11.priv.proxad.net>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: SCSC
- References: <CGME20180312133446epcas1p2c0b1934921ed5c33ccf5e9aaaf9f6a9c@epcas1p2.samsung.com> <1328064061.551458859.1520861039419.JavaMail.root@zimbra62-e11.priv.proxad.net>
On Mon, 12 Mar 2018 14:23:59 +0100
Antoine C. <acalando@xxxxxxx> wrote:
> I have a problem with a script starting several subshells in
> background then checking their return code. It looks like the "wait
> <PID>" builtin is sometimes returning the error code of another child.
>
> Is it a bug or am I missing something?
It's a bug. You hit a race where we record the status but don't
read it back properly.
Thanks, I had no problem investigating with that script.
pws
diff --git a/Src/jobs.c b/Src/jobs.c
index 503618f..330ee6b 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -2289,8 +2289,11 @@ bin_fg(char *name, char **argv, Options ops, int func)
*/
retval = waitforpid(pid, 1);
}
- if (retval == 0)
- retval = lastval2;
+ if (retval == 0) {
+ if ((retval = getbgstatus(pid)) < 0) {
+ retval = lastval2;
+ }
+ }
} else if ((retval = getbgstatus(pid)) < 0) {
zwarnnam(name, "pid %d is not a child of this shell", pid);
/* presumably lastval2 doesn't tell us a heck of a lot? */
Messages sorted by:
Reverse Date,
Date,
Thread,
Author