mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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
This commit is contained in:
parent
c678c727a6
commit
8f6794dda3
1 changed files with 9 additions and 15 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue