extern procenv_t wait_intr_buf;
extern int wait_signal_received;
-pid_t last_made_pid = NO_PID;
-pid_t last_asynchronous_pid = NO_PID;
+volatile pid_t last_made_pid = NO_PID;
+volatile pid_t last_asynchronous_pid = NO_PID;
/* Call this when you start making children. */
int already_making_children = 0;
WAIT status;
CHECK_TERMSIG;
+ CHECK_WAIT_INTR;
while ((pid = waitpid (-1, (int *)&status, WNOHANG)) > 0)
set_pid_status (pid, status);
# endif /* WNOHANG */
CHECK_TERMSIG;
+ CHECK_WAIT_INTR;
}
#endif /* WAITPID */
sync_buffered_stream (default_buffered_input);
#endif /* BUFFERED_INPUT */
+ /* XXX - block SIGTERM here and unblock in child after fork resets the
+ set of pending signals? */
+ RESET_SIGTERM;
+
/* Create the child, handle severe errors. Retry on EAGAIN. */
forksleep = 1;
while ((pid = fork ()) < 0 && errno == EAGAIN && forksleep < FORKSLEEP_MAX)
{
sys_error ("fork: retry");
+ RESET_SIGTERM;
+
#if defined (HAVE_WAITPID)
/* Posix systems with a non-blocking waitpid () system call available
get another chance after zombies are reaped. */
forksleep <<= 1;
}
+ if (pid != 0)
+ RESET_SIGTERM;
+
if (pid < 0)
{
sys_error ("fork");
while ((got_pid = WAITPID (pid, &status, 0)) != pid)
{
CHECK_TERMSIG;
+ CHECK_WAIT_INTR;
if (got_pid < 0)
{
if (errno != EINTR && errno != ECHILD)
signal_is_trapped (SIGINT) &&
((sigint_handler = trap_to_sighandler (SIGINT)) == trap_handler))
{
- last_command_exit_value = EXECUTION_FAILURE;
+ last_command_exit_value = 128+SIGINT;
restore_sigint_handler ();
interrupt_immediately = 0;
trap_handler (SIGINT); /* set pending_traps[SIGINT] */
wait_signal_received = SIGINT;
- longjmp (wait_intr_buf, 1);
+ SIGRETURN (0);
}
if (interrupt_immediately)
while ((got_pid = WAITPID (-1, &status, 0)) != pid) /* XXX was pid now -1 */
{
CHECK_TERMSIG;
+ CHECK_WAIT_INTR;
if (got_pid < 0 && errno == ECHILD)
{
#if !defined (_POSIX_VERSION)
reap_zombie_children ();
#endif /* HAVE_WAITPID */
+ CHECK_TERMSIG;
+ CHECK_WAIT_INTR;
+
if (interactive_shell == 0)
{
SigHandler *temp_handler;