diff options
author | Ed Schouten <ed@FreeBSD.org> | 2010-04-30 22:33:49 +0000 |
---|---|---|
committer | Ed Schouten <ed@FreeBSD.org> | 2010-04-30 22:33:49 +0000 |
commit | e1e9ba3370d01ab5448943461a07d6d183a15bf1 (patch) | |
tree | 09ce6a985c822526d2607a488f75f6372d41dfd3 /usr.bin | |
parent | 7bec141b121da05bad35c061c1e9ab17f47c71d7 (diff) | |
download | src-e1e9ba3370d01ab5448943461a07d6d183a15bf1.tar.gz src-e1e9ba3370d01ab5448943461a07d6d183a15bf1.zip |
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
Notes
Notes:
svn path=/head/; revision=207453
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/script/script.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/usr.bin/script/script.c b/usr.bin/script/script.c index 6c4e0ee4db37..a21785abbc4f 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 |