mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-22 03:02:06 +03:00
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:
parent
e9c1eb64bd
commit
9c3b434197
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user