Ticket #2273: Restore signals even if fork() fails.

The -1 is not sent through WEXITSTATUS() in case of wait()
failing any more. I think that's the original intention.
This commit is contained in:
Oswald Buddenhagen 2010-04-17 21:16:36 +02:00 committed by Andrew Borodin
parent e9c1eb64bd
commit 9c3b434197

View File

@ -167,9 +167,9 @@ my_system (int flags, const char *shell, const char *command)
if (pid < 0)
{
fprintf (stderr, "\n\nfork () = -1\n");
return -1;
status = -1;
}
if (pid == 0)
else if (pid == 0)
{
signal (SIGINT, SIG_DFL);
signal (SIGQUIT, SIG_DFL);
@ -204,18 +204,25 @@ my_system (int flags, const char *shell, const char *command)
}
else
{
while (waitpid (pid, &status, 0) < 0)
while (TRUE)
{
if (waitpid (pid, &status, 0) > 0)
{
status = WEXITSTATUS(status);
break;
}
if (errno != EINTR)
{
status = -1;
break;
}
}
}
sigaction (SIGINT, &save_intr, NULL);
sigaction (SIGQUIT, &save_quit, NULL);
sigaction (SIGTSTP, &save_stop, NULL);
return WEXITSTATUS (status);
return status;
}