diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-08-21 21:41:14 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2017-08-21 21:41:14 +0000 |
commit | c2cdcf41ccf92e65434001bc73d5d81b4c4210dd (patch) | |
tree | b806cd4f2e6e8fcd9ec7d6f315a0aa469b48521d /usr.bin/m4 | |
parent | e9d6f86c3468c07e6b1b12c0dd0b46516528e450 (diff) |
Use waitpid()/EINTR idiom for the specific pid, rather than generic wait(),
in case the parent process was started with a dangling child. This style
ensures any potential parent:child interlock isn't disrupted due to the
"wrong" child being waited on first. Then the other other childs can safely
zombie.
ok millert jca brynet
Diffstat (limited to 'usr.bin/m4')
-rw-r--r-- | usr.bin/m4/gnum4.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/usr.bin/m4/gnum4.c b/usr.bin/m4/gnum4.c index 4280cb97339..1de66f2fa1b 100644 --- a/usr.bin/m4/gnum4.c +++ b/usr.bin/m4/gnum4.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gnum4.c,v 1.51 2017/06/15 13:48:42 bcallah Exp $ */ +/* $OpenBSD: gnum4.c,v 1.52 2017/08/21 21:41:13 deraadt Exp $ */ /* * Copyright (c) 1999 Marc Espie @@ -630,7 +630,7 @@ void doesyscmd(const char *cmd) { int p[2]; - pid_t pid, cpid; + pid_t cpid; char *argv[4]; int cc; int status; @@ -668,8 +668,10 @@ doesyscmd(const char *cmd) } while (cc > 0 || (cc == -1 && errno == EINTR)); (void) close(p[0]); - while ((pid = wait(&status)) != cpid && pid >= 0) - continue; + while (waitpid(cpid, &status, 0) == -1) { + if (errno != EINTR) + break; + } pbstr(getstring()); } } |