Mercurial > dovecot > core-2.2
changeset 4251:5bc987dc62a8 HEAD
Added lib_signals_ignore_signal() and made lib_signals_set_handler() with
NULL handler not restart syscall.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 04 May 2006 01:54:38 +0300 |
parents | a767dd4fafb0 |
children | ec4782b057f0 |
files | src/lib/lib-signals.c src/lib/lib-signals.h |
diffstat | 2 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/lib-signals.c Thu May 04 01:02:55 2006 +0300 +++ b/src/lib/lib-signals.c Thu May 04 01:54:38 2006 +0300 @@ -51,6 +51,10 @@ } } +static void sig_ignore(int signo __attr_unused__) +{ +} + static void signal_read(void *context __attr_unused__) { unsigned char signal_buf[512]; @@ -110,7 +114,7 @@ if (sigemptyset(&act.sa_mask) < 0) i_fatal("sigemptyset(): %m"); act.sa_flags = 0; - act.sa_handler = handler != NULL ? sig_handler : SIG_IGN; + act.sa_handler = handler != NULL ? sig_handler : sig_ignore; if (sigaction(signo, &act, NULL) < 0) i_fatal("sigaction(%d): %m", signo); @@ -140,6 +144,26 @@ signal_handlers[signo] = h; } +void lib_signals_ignore_signal(int signo) +{ + 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"); + act.sa_flags = SA_RESTART; + act.sa_handler = SIG_IGN; + + if (sigaction(signo, &act, NULL) < 0) + i_fatal("sigaction(%d): %m", signo); +} + void lib_signals_unset_handler(int signo, signal_handler_t *handler, void *context) {
--- a/src/lib/lib-signals.h Thu May 04 01:02:55 2006 +0300 +++ b/src/lib/lib-signals.h Thu May 04 01:54:38 2006 +0300 @@ -10,6 +10,9 @@ the signal is ignored. */ void lib_signals_set_handler(int signo, bool delayed, signal_handler_t *handler, void *context); +/* Ignore given signal. The difference to lib_signals_set_handler() with NULL + handler is that this function tries to restart the system calls. */ +void lib_signals_ignore_signal(int signo); void lib_signals_unset_handler(int signo, signal_handler_t *handler, void *context);