From c2cdcf41ccf92e65434001bc73d5d81b4c4210dd Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Mon, 21 Aug 2017 21:41:14 +0000 Subject: 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 --- usr.bin/tput/tput.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'usr.bin/tput') diff --git a/usr.bin/tput/tput.c b/usr.bin/tput/tput.c index 8289ad3d2f3..e3fa82c3812 100644 --- a/usr.bin/tput/tput.c +++ b/usr.bin/tput/tput.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tput.c,v 1.22 2015/11/16 03:03:28 deraadt Exp $ */ +/* $OpenBSD: tput.c,v 1.23 2017/08/21 21:41:13 deraadt Exp $ */ /* * Copyright (c) 1999 Todd C. Miller @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -269,9 +270,10 @@ init(void) size_t len; char *buf; int wstatus; + pid_t pid; if (init_prog && !issetugid()) { - switch (vfork()) { + switch (pid = vfork()) { case -1: err(4, "vfork"); break; @@ -281,7 +283,10 @@ init(void) _exit(127); break; default: - wait(&wstatus); + while (waitpid(pid, &wstatus, 0) == -1) { + if (errno != EINTR) + break; + } /* parent */ break; } -- cgit v1.2.3