In waitpid emulation, restart waiting after signals.

This matches the semantics the original hush code obtained by using the SA_RESTART flag when installing signal handlers, and avoids error messages about waitpid being interrupted.
This commit is contained in:
Stephen Heumann 2015-01-15 18:45:42 -06:00
parent 656769d136
commit 3d106c6708
1 changed files with 9 additions and 0 deletions

View File

@ -84,6 +84,7 @@ pid_t waitpid_emul (pid_t pid, int *stat_loc, int options)
sig_t prev_sig;
int prev_errno;
restart:
if (options & WNOHANG) {
/* Arrange for a signal to interrupt the wait to simulate
* non-blocking semantics. This might cause spurious
@ -108,9 +109,17 @@ pid_t waitpid_emul (pid_t pid, int *stat_loc, int options)
* as a successful return with no finished child found. */
errno = prev_errno;
return 0;
} else {
errno = wait_errno;
}
}
if (p == -1 && errno == EINTR) {
/* Hush originally set SA_RESTART option on all caught signals.
* GNO doesn't have this, so try to emulate it here. */
goto restart;
}
if (p < 0)
return p;
if (p == pid || pid == -1)