26 FDEBUG(1) <<
"in sigusr2 handler\n";
28 cerr <<
"User signal SIGINT terminating the process\n";
41 abort_on_error(
int const errcode)
44 perror(
"UnixSignalHandlers::setupSignal: sig function failed");
50 reenableSigs(sigset_t* oldset)
52 abort_on_error(pthread_sigmask(SIG_SETMASK, oldset, 0));
59 memset(&act, 0,
sizeof(act));
60 act.sa_sigaction =
func;
61 act.sa_flags = SA_RESTART;
63 if (mysig == SIGKILL) {
64 cerr <<
"Cannot install handler for KILL signal\n";
66 }
else if (mysig == SIGSTOP) {
67 cerr <<
"Cannot install handler for STOP signal\n";
70 abort_on_error(sigaction(mysig, &act,
nullptr));
72 abort_on_error(sigemptyset(&newset));
73 abort_on_error(sigaddset(&newset, mysig));
74 abort_on_error(pthread_sigmask(SIG_UNBLOCK, &newset, 0));
82 abort_on_error(sigemptyset(&myset));
83 struct sigaction tmpact;
84 memset(&tmpact, 0,
sizeof(tmpact));
85 tmpact.sa_handler = SIG_IGN;
86 for (
int num = SIGRTMIN;
num < SIGRTMAX; ++
num) {
87 abort_on_error(sigaddset(&myset,
num));
88 abort_on_error(sigaction(
num, &tmpact,
nullptr));
90 abort_on_error(pthread_sigmask(SIG_BLOCK, &myset, 0));
95 disableAllSigs(sigset_t* oldset)
98 abort_on_error(sigfillset(&myset));
99 abort_on_error(pthread_sigmask(SIG_SETMASK, &myset, oldset));
106 disableAllSigs(&oldset);
110 installSig(signum, func);
111 reenableSigs(&oldset);
122 if (want_sigint_enabled) {
std::atomic< int > shutdown_flag
static void handle_sigusr2(int which, siginfo_t *, void *)
void setupSignals(bool want_sigint_enabled)
void(*)(int, siginfo_t *, void *) my_sigaction_func_t