[dovecot-cvs] dovecot/src/lib lib-signals.c, 1.11, 1.12 lib-signals.h, 1.5, 1.6

cras at dovecot.org cras at dovecot.org
Thu May 4 01:54:40 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv24859/lib

Modified Files:
	lib-signals.c lib-signals.h 
Log Message:
Added lib_signals_ignore_signal() and made lib_signals_set_handler() with
NULL handler not restart syscall.



Index: lib-signals.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/lib-signals.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- lib-signals.c	14 Jan 2006 18:47:22 -0000	1.11
+++ lib-signals.c	3 May 2006 22:54:38 -0000	1.12
@@ -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)
 {

Index: lib-signals.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/lib-signals.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- lib-signals.h	13 Jan 2006 20:26:01 -0000	1.5
+++ lib-signals.h	3 May 2006 22:54:38 -0000	1.6
@@ -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);
 



More information about the dovecot-cvs mailing list