mirror of
https://github.com/sheumann/hush.git
synced 2024-09-27 06:54:26 +00:00
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:
parent
656769d136
commit
3d106c6708
@ -84,6 +84,7 @@ pid_t waitpid_emul (pid_t pid, int *stat_loc, int options)
|
|||||||
sig_t prev_sig;
|
sig_t prev_sig;
|
||||||
int prev_errno;
|
int prev_errno;
|
||||||
|
|
||||||
|
restart:
|
||||||
if (options & WNOHANG) {
|
if (options & WNOHANG) {
|
||||||
/* Arrange for a signal to interrupt the wait to simulate
|
/* Arrange for a signal to interrupt the wait to simulate
|
||||||
* non-blocking semantics. This might cause spurious
|
* 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. */
|
* as a successful return with no finished child found. */
|
||||||
errno = prev_errno;
|
errno = prev_errno;
|
||||||
return 0;
|
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)
|
if (p < 0)
|
||||||
return p;
|
return p;
|
||||||
if (p == pid || pid == -1)
|
if (p == pid || pid == -1)
|
||||||
|
Loading…
Reference in New Issue
Block a user