Compare commits
No commits in common. "66365e15a70f49f2247a510e94cfce85ba647301" and "fe9827bbeb609ae4a27856b552db9216543ec3e4" have entirely different histories.
66365e15a7
...
fe9827bbeb
@ -8,8 +8,6 @@
|
|||||||
|
|
||||||
typedef int sig_atomic_t;
|
typedef int sig_atomic_t;
|
||||||
|
|
||||||
#define SIG_ERR (__simple_sighandler_t)(-3)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -21,9 +19,6 @@ extern "C"
|
|||||||
int sigaction(int signo, const struct sigaction* act, struct sigaction* oldact);
|
int sigaction(int signo, const struct sigaction* act, struct sigaction* oldact);
|
||||||
#pragma GCC pop_options
|
#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. */
|
/* Send a signal to a specific process. */
|
||||||
int kill(pid_t pid, int signo);
|
int kill(pid_t pid, int signo);
|
||||||
|
|
||||||
|
@ -13,18 +13,6 @@ extern "C"
|
|||||||
__errno_return(rc, int);
|
__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)
|
int kill(pid_t pid, int signo)
|
||||||
{
|
{
|
||||||
long rc = syscall(SYS_kill, pid, signo);
|
long rc = syscall(SYS_kill, pid, signo);
|
||||||
|
@ -191,6 +191,9 @@ extern "C"
|
|||||||
return S_ISREG(st.st_mode);
|
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();
|
pid_t child = fork();
|
||||||
if (child == 0)
|
if (child == 0)
|
||||||
{
|
{
|
||||||
@ -200,21 +203,9 @@ extern "C"
|
|||||||
|
|
||||||
if (child < 0) return -1;
|
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;
|
int status;
|
||||||
waitpid(child, &status, 0);
|
waitpid(child, &status, 0);
|
||||||
|
|
||||||
sigprocmask(SIG_SETMASK, &oldset, nullptr);
|
|
||||||
signal(SIGINT, old_int);
|
|
||||||
signal(SIGQUIT, old_quit);
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user