m4: import patch from OpenBSD

Use waitpid()/EINTR idiom for the specific pid, rather than generic wait()

Patch by: deraadt@

Obtained from:	OpenBSD
This commit is contained in:
Baptiste Daroussin 2019-09-09 15:24:48 +00:00
parent d031bd192e
commit fdb905e20f

View File

@ -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 $ */
/*- /*-
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
@ -634,7 +634,7 @@ void
doesyscmd(const char *cmd) doesyscmd(const char *cmd)
{ {
int p[2]; int p[2];
pid_t pid, cpid; pid_t cpid;
char *argv[4]; char *argv[4];
int cc; int cc;
int status; int status;
@ -672,8 +672,10 @@ doesyscmd(const char *cmd)
} while (cc > 0 || (cc == -1 && errno == EINTR)); } while (cc > 0 || (cc == -1 && errno == EINTR));
(void) close(p[0]); (void) close(p[0]);
while ((pid = wait(&status)) != cpid && pid >= 0) while (waitpid(cpid, &status, 0) == -1) {
continue; if (errno != EINTR)
break;
}
pbstr(getstring()); pbstr(getstring());
} }
} }