[dovecot-cvs] dovecot/src/pop3 main.c,1.26,1.27

cras at dovecot.org cras at dovecot.org
Sun Sep 25 14:07:43 EEST 2005


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

Modified Files:
	main.c 
Log Message:
Implemented new signal handling framework, which makes handling signals much
easier.



Index: main.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/pop3/main.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- main.c	11 Sep 2005 10:52:02 -0000	1.26
+++ main.c	25 Sep 2005 11:07:41 -0000	1.27
@@ -45,8 +45,12 @@
 const char *uidl_format, *logout_format;
 enum uidl_keys uidl_keymask;
 
-static void sig_quit(int signo __attr_unused__)
+static void sig_die(int signo, void *context __attr_unused__)
 {
+	/* warn about being killed because of some signal, except SIGINT (^C)
+	   which is too common at least while testing :) */
+	if (signo != SIGINT)
+		i_warning("Killed with signal %d", signo);
 	io_loop_stop(ioloop);
 }
 
@@ -147,7 +151,10 @@
 	struct mail_storage *storage;
 	const char *str, *mail;
 
-	lib_init_signals(sig_quit);
+	lib_signals_init();
+        lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL);
+        lib_signals_set_handler(SIGTERM, TRUE, sig_die, NULL);
+        lib_signals_set_handler(SIGPIPE, FALSE, NULL, NULL);
 
 	if (getenv("USER") == NULL)
 		i_fatal("USER environment missing");
@@ -236,17 +243,13 @@
 
 static void main_deinit(void)
 {
-	/* warn about being killed because of some signal, except SIGINT (^C)
-	   which is too common at least while testing :) */
-	if (lib_signal_kill != 0 && lib_signal_kill != 2)
-		i_warning("Killed with signal %d", lib_signal_kill);
-
 	module_dir_unload(modules);
 
 	clients_deinit();
         mail_storage_deinit();
 	random_deinit();
 
+	lib_signals_deinit();
 	closelog();
 }
 



More information about the dovecot-cvs mailing list