diff --git a/libc/src/stdlib.cpp b/libc/src/stdlib.cpp index c98ff791..32150fc7 100644 --- a/libc/src/stdlib.cpp +++ b/libc/src/stdlib.cpp @@ -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; }