summaryrefslogtreecommitdiffstats
path: root/usr.bin/script
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2010-04-30 22:33:49 +0000
committered <ed@FreeBSD.org>2010-04-30 22:33:49 +0000
commit83a9d5d7455091b609ad7183f2a3f9216d8982e0 (patch)
tree09ce6a985c822526d2607a488f75f6372d41dfd3 /usr.bin/script
parent94779e71c30c7ed31273bb723318146a4e2288ba (diff)
downloadFreeBSD-src-83a9d5d7455091b609ad7183f2a3f9216d8982e0.zip
FreeBSD-src-83a9d5d7455091b609ad7183f2a3f9216d8982e0.tar.gz
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 MFC after: 2 weeks
Diffstat (limited to 'usr.bin/script')
-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 6c4e0ee..a21785a 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