Compare commits

..

No commits in common. "66365e15a70f49f2247a510e94cfce85ba647301" and "fe9827bbeb609ae4a27856b552db9216543ec3e4" have entirely different histories.

3 changed files with 3 additions and 29 deletions

View File

@ -8,8 +8,6 @@
typedef int sig_atomic_t;
#define SIG_ERR (__simple_sighandler_t)(-3)
#ifdef __cplusplus
extern "C"
{
@ -21,9 +19,6 @@ extern "C"
int sigaction(int signo, const struct sigaction* act, struct sigaction* oldact);
#pragma GCC pop_options
/* Change the current thread's signal disposition for a specific signal. */
__simple_sighandler_t signal(int signo, __simple_sighandler_t handler);
/* Send a signal to a specific process. */
int kill(pid_t pid, int signo);

View File

@ -13,18 +13,6 @@ extern "C"
__errno_return(rc, int);
}
__simple_sighandler_t signal(int signo, __simple_sighandler_t handler)
{
struct sigaction act, oldact;
act.sa_handler = handler;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
if (sigaction(signo, &act, &oldact) < 0) return SIG_ERR;
return oldact.sa_handler;
}
int kill(pid_t pid, int signo)
{
long rc = syscall(SYS_kill, pid, signo);

View File

@ -191,6 +191,9 @@ 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)
{
@ -200,21 +203,9 @@ 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;
}