Implement signals, finally! #30

Merged
apio merged 14 commits from finally-signals into main 2023-07-10 20:16:00 +00:00
Showing only changes of commit 66365e15a7 - Show all commits

View File

@ -191,9 +191,6 @@ extern "C"
return S_ISREG(st.st_mode);
}
// FIXME: During the execution of system(), SIGCHLD will be blocked, and SIGINT and SIGQUIT will be ignored, in
// the process that calls system().
pid_t child = fork();
if (child == 0)
{
@ -203,9 +200,21 @@ extern "C"
if (child < 0) return -1;
sigset_t set, oldset;
sigemptyset(&set);
sigaddset(&set, SIGCHLD);
sigprocmask(SIG_BLOCK, &set, &oldset);
auto old_int = signal(SIGINT, SIG_IGN);
auto old_quit = signal(SIGQUIT, SIG_IGN);
int status;
waitpid(child, &status, 0);
sigprocmask(SIG_SETMASK, &oldset, nullptr);
signal(SIGINT, old_int);
signal(SIGQUIT, old_quit);
return status;
}