1
0
mirror of https://github.com/janet-lang/janet synced 2024-12-23 15:00:27 +00:00

Use pthread_sigmask when adding signal handlers.

This commit is contained in:
Calvin Rose 2023-08-19 17:30:55 -05:00
parent f45571033c
commit 08e20e912d

View File

@ -815,7 +815,11 @@ static void janet_signal_callback(JanetEVGenericMessage msg) {
sigset_t set;
sigemptyset(&set);
sigaddset(&set, sig);
#ifdef JANET_THREADS
pthread_sigmask(SIG_BLOCK, &set, NULL);
#else
sigprocmask(SIG_BLOCK, &set, NULL);
#endif
raise(sig);
return;
}
@ -881,6 +885,14 @@ JANET_CORE_FN(os_sigaction,
}
action.sa_mask = mask;
RETRY_EINTR(rc, sigaction(sig, &action, NULL));
sigset_t set;
sigemptyset(&set);
sigaddset(&set, sig);
#ifdef JANET_THREADS
pthread_sigmask(SIG_UNBLOCK, &set, NULL);
#else
sigprocmask(SIG_UNBLOCK, &set, NULL);
#endif
return janet_wrap_nil();
#endif
}