16 #elif defined(__DARWIN_NSIG) 17 #define NSIG __DARWIN_NSIG 33 FDEBUG(1) <<
"in sigusr2 handler\n";
35 std::cerr <<
"User signal SIGINT terminating the process\n";
46 #if defined(__linux__) 57 std::lock_guard<decltype(signum_lock)> lock{signum_lock};
58 int const rc{signum_value};
63 #define MUST_BE_ZERO(fun) \ 65 perror("UnixSignalHandlers::setupSignal: sig function failed"); \ 77 MUST_BE_ZERO(pthread_sigmask(SIG_SETMASK, &myset, oldset));
85 #if defined(__linux__) 90 struct sigaction tmpact;
91 memset(&tmpact, 0,
sizeof(tmpact));
92 tmpact.sa_handler = SIG_IGN;
94 for (
int num = SIGRTMIN; num < SIGRTMAX; ++num) {
137 #if defined(__linux__) 150 struct sigaction act;
151 memset(&act, 0,
sizeof(act));
152 act.sa_sigaction = func;
153 act.sa_flags = SA_RESTART;
157 if (mysig == SIGKILL) {
158 perror(
"Cannot install handler for KILL signal");
160 }
else if (mysig == SIGSTOP) {
161 perror(
"Cannot install handler for STOP signal");
165 if (sigaction(mysig, &act,
nullptr) != 0) {
166 perror(
"sigaction failed");
181 sigset_t tmpset, oldset;
188 MUST_BE_ZERO(pthread_sigmask(SIG_SETMASK, &tmpset, &oldset));
190 for (
int k = 1; k < NSIG; ++k) {
191 std::cerr <<
"sigismember is " << sigismember(&tmpset, k)
192 <<
" for signal " << std::setw(2) << k
193 #if defined(__linux__) 194 <<
" (" << strsignal(k) <<
")" 199 MUST_BE_ZERO(pthread_sigmask(SIG_SETMASK, &oldset, &tmpset));
208 if (want_sigint_enabled)
std::atomic< int > shutdown_flag
void disableSignal(sigset_t *newset, const int signum)
void reenableSigs(sigset_t *oldset)
volatile int signum_value
void disableAllSigs(sigset_t *oldset)
void setupSignals(bool want_sigint_enabled)
void ep_sigusr2(int which, siginfo_t *, void *)
void(*)(int, siginfo_t *, void *) CFUNC
void installCustomHandler(const int signum, CFUNC func)
#define MUST_BE_ZERO(fun)
void enableSignal(sigset_t *newset, const int signum)
void installSig(const int signum, CFUNC func)