version 1.158, 2020/01/13 16:03:44 |
version 1.159, 2020/01/16 16:07:18 |
|
|
static volatile sig_atomic_t got_SIGINT, got_SIGHUP, got_SIGQUIT, got_SIGTERM, |
static volatile sig_atomic_t got_SIGINT, got_SIGHUP, got_SIGQUIT, got_SIGTERM, |
got_SIGINFO; |
got_SIGINFO; |
|
|
static sigset_t sigset, emptyset; |
static sigset_t sigset, emptyset, origset; |
|
|
static void handle_fatal_signal(int); |
static void handle_fatal_signal(int); |
static void handle_siginfo(void); |
static void handle_siginfo(void); |
|
|
} |
} |
} |
} |
|
|
|
void |
|
Sigset_Init() |
|
{ |
|
sigemptyset(&emptyset); |
|
sigprocmask(SIG_BLOCK, &emptyset, &origset); |
|
} |
|
|
static void |
static void |
setup_all_signals(void) |
setup_all_signals(void) |
{ |
{ |
sigemptyset(&sigset); |
sigemptyset(&sigset); |
sigemptyset(&emptyset); |
|
/* |
/* |
* Catch the four signals that POSIX specifies if they aren't ignored. |
* Catch the four signals that POSIX specifies if they aren't ignored. |
* handle_signal will take care of calling JobInterrupt if appropriate. |
* handle_signal will take care of calling JobInterrupt if appropriate. |
|
|
return reaped; |
return reaped; |
} |
} |
|
|
|
void |
|
reset_signal_mask() |
|
{ |
|
sigprocmask(SIG_SETMASK, &origset, NULL); |
|
} |
|
|
void |
void |
handle_running_jobs(void) |
handle_running_jobs(void) |
{ |
{ |
sigset_t old; |
|
/* reaping children in the presence of caught signals */ |
/* reaping children in the presence of caught signals */ |
|
|
/* first, we make sure to hold on new signals, to synchronize |
/* first, we make sure to hold on new signals, to synchronize |
* reception of new stuff on sigsuspend |
* reception of new stuff on sigsuspend |
*/ |
*/ |
sigprocmask(SIG_BLOCK, &sigset, &old); |
sigprocmask(SIG_BLOCK, &sigset, NULL); |
/* note this will NOT loop until runningJobs == NULL. |
/* note this will NOT loop until runningJobs == NULL. |
* It's merely an optimisation, namely that we don't need to go |
* It's merely an optimisation, namely that we don't need to go |
* through the logic if no job is present. As soon as a job |
* through the logic if no job is present. As soon as a job |
|
|
*/ |
*/ |
sigsuspend(&emptyset); |
sigsuspend(&emptyset); |
} |
} |
sigprocmask(SIG_SETMASK, &old, NULL); |
reset_signal_mask(); |
} |
} |
|
|
void |
void |