summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-05-14 12:34:06 +0000
committered <ed@FreeBSD.org>2010-05-14 12:34:06 +0000
commitcbd656ffa4cb161401f58f6b2b12b15ab8021f58 (patch)
tree2dd474cad0b7db852874371960ee4c3dc666f96b /usr.bin
parente764fbe1a5e3ecbaec7949d24302c7b52c93ffe4 (diff)
downloadFreeBSD-src-cbd656ffa4cb161401f58f6b2b12b15ab8021f58.zip
FreeBSD-src-cbd656ffa4cb161401f58f6b2b12b15ab8021f58.tar.gz
MFC r207453:
Remove WNOHANG flag from wait3(). Because script(1) now reliably terminates when the TTY is closed, it may be the case that the call to wait3() occurs just before the child process exits. This causes error codes to be ignored. Just change script(1) to use waitpid() instead of wait3(). This makes it more portable and prevents the need for a loop, since waitpid() only returns a specified process. PR: bin/146189 Tested by: amdmi3@, older version
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/script/script.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c
index ef4d3ef..b571606 100644
--- a/usr.bin/script/script.c
+++ b/usr.bin/script/script.c
@@ -219,23 +219,17 @@ usage(void)
void
finish(void)
{
- pid_t pid;
- int die, e, status;
+ int e, status;
- die = e = 0;
- while ((pid = wait3(&status, WNOHANG, 0)) > 0)
- if (pid == child) {
- die = 1;
- if (WIFEXITED(status))
- e = WEXITSTATUS(status);
- else if (WIFSIGNALED(status))
- e = WTERMSIG(status);
- else /* can't happen */
- e = 1;
- }
-
- if (die)
+ if (waitpid(child, &status, 0) == child) {
+ if (WIFEXITED(status))
+ e = WEXITSTATUS(status);
+ else if (WIFSIGNALED(status))
+ e = WTERMSIG(status);
+ else /* can't happen */
+ e = 1;
done(e);
+ }
}
void
OpenPOWER on IntegriCloud