signal_handler_switch_ioloop(h);
}
-void lib_signals_ignore(int signo, bool restart_syscalls)
+static void lib_signals_ignore_forced(int signo, bool restart_syscalls)
{
struct sigaction act;
- if (signo < 0 || signo > MAX_SIGNAL_VALUE) {
- i_panic("Trying to ignore signal %d, but max is %d",
- signo, MAX_SIGNAL_VALUE);
- }
-
- i_assert(signal_handlers[signo] == NULL);
-
if (sigemptyset(&act.sa_mask) < 0)
i_fatal("sigemptyset(): %m");
if (restart_syscalls) {
i_fatal("sigaction(%d): %m", signo);
}
-static void lib_signals_restore_system_default(int signo)
+void lib_signals_ignore(int signo, bool restart_syscalls)
{
- struct sigaction act;
+ if (signo < 0 || signo > MAX_SIGNAL_VALUE) {
+ i_panic("Trying to ignore signal %d, but max is %d",
+ signo, MAX_SIGNAL_VALUE);
+ }
- if (sigemptyset(&act.sa_mask) < 0)
- i_fatal("sigemptyset(): %m");
- act.sa_flags = 0;
- act.sa_handler = SIG_DFL;
- if (sigaction(signo, &act, NULL) < 0)
- i_fatal("sigaction(%d): %m", signo);
+ i_assert(signal_handlers[signo] == NULL);
+
+ lib_signals_ignore_forced(signo, restart_syscalls);
}
-void lib_signals_clear_handlers(int signo)
+void lib_signals_clear_handlers_and_ignore(int signo)
{
struct signal_handler *h;
if (signal_handlers[signo] == NULL)
return;
- lib_signals_restore_system_default(signo);
+ lib_signals_ignore_forced(signo, TRUE);
h = signal_handlers[signo];
signal_handlers[signo] = NULL;
if (p == &signal_handlers[signo] &&
(*p)->next == NULL) {
/* last handler is to be removed */
- lib_signals_restore_system_default(signo);
+ lib_signals_ignore_forced(signo, TRUE);
}
h = *p;
*p = h->next;
for (i = 0; i < MAX_SIGNAL_VALUE; i++) {
if (signal_handlers[i] != NULL)
- lib_signals_clear_handlers(i);
+ lib_signals_clear_handlers_and_ignore(i);
}
i_assert(signals_expected == 0);
ATTR_NULL(4);
/* Ignore given signal. */
void lib_signals_ignore(int signo, bool restart_syscalls);
-/* Clear all signal handlers for a specific signal and restore default system
- handler. */
-void lib_signals_clear_handlers(int signo);
+/* Clear all signal handlers for a specific signal and set the signal to be
+ ignored. */
+void lib_signals_clear_handlers_and_ignore(int signo);
/* Unset specific signal handler for specific signal. */
void lib_signals_unset_handler(int signo,
signal_handler_t *handler, void *context)