dovecot-1.2: When a process is killed, show the signal code and ...

dovecot at dovecot.org dovecot at dovecot.org
Wed Apr 1 20:13:11 EEST 2009


details:   http://hg.dovecot.org/dovecot-1.2/rev/5361cb6afe9e
changeset: 8883:5361cb6afe9e
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Apr 01 13:13:04 2009 -0400
description:
When a process is killed, show the signal code and the sending process's pid and uid.

diffstat:

9 files changed, 81 insertions(+), 14 deletions(-)
src/auth/main.c         |    8 ++++++--
src/deliver/deliver.c   |    8 ++++++--
src/dict/main.c         |    8 ++++++--
src/imap/main.c         |    8 ++++++--
src/lib/lib-signals.c   |   36 ++++++++++++++++++++++++++++++++++++
src/lib/lib-signals.h   |    3 +++
src/login-common/main.c |    8 ++++++--
src/master/main.c       |    8 ++++++--
src/pop3/main.c         |    8 ++++++--

diffs (185 lines):

diff -r 9f3968f49ceb -r 5361cb6afe9e src/auth/main.c
--- a/src/auth/main.c	Wed Apr 01 12:52:46 2009 -0400
+++ b/src/auth/main.c	Wed Apr 01 13:13:04 2009 -0400
@@ -42,8 +42,12 @@ static void sig_die(const siginfo_t *si,
 {
 	/* warn about being killed because of some signal, except SIGINT (^C)
 	   which is too common at least while testing :) */
-	if (si->si_signo != SIGINT)
-		i_warning("Killed with signal %d", si->si_signo);
+	if (si->si_signo != SIGINT) {
+		i_warning("Killed with signal %d (by pid=%s uid=%s code=%s)",
+			  si->si_signo, dec2str(si->si_pid),
+			  dec2str(si->si_uid),
+			  lib_signal_code_to_str(si->si_signo, si->si_code));
+	}
 	io_loop_stop(ioloop);
 }
 
diff -r 9f3968f49ceb -r 5361cb6afe9e src/deliver/deliver.c
--- a/src/deliver/deliver.c	Wed Apr 01 12:52:46 2009 -0400
+++ b/src/deliver/deliver.c	Wed Apr 01 13:13:04 2009 -0400
@@ -74,8 +74,12 @@ static void sig_die(const siginfo_t *si,
 {
 	/* warn about being killed because of some signal, except SIGINT (^C)
 	   which is too common at least while testing :) */
-	if (si->si_signo != SIGINT)
-		i_warning("Killed with signal %d", si->si_signo);
+	if (si->si_signo != SIGINT) {
+		i_warning("Killed with signal %d (by pid=%s uid=%s code=%s)",
+			  si->si_signo, dec2str(si->si_pid),
+			  dec2str(si->si_uid),
+			  lib_signal_code_to_str(si->si_signo, si->si_code));
+	}
 	io_loop_stop(current_ioloop);
 }
 
diff -r 9f3968f49ceb -r 5361cb6afe9e src/dict/main.c
--- a/src/dict/main.c	Wed Apr 01 12:52:46 2009 -0400
+++ b/src/dict/main.c	Wed Apr 01 13:13:04 2009 -0400
@@ -27,8 +27,12 @@ static void sig_die(const siginfo_t *si,
 {
 	/* warn about being killed because of some signal, except SIGINT (^C)
 	   which is too common at least while testing :) */
-	if (si->si_signo != SIGINT)
-		i_warning("Killed with signal %d", si->si_signo);
+	if (si->si_signo != SIGINT) {
+		i_warning("Killed with signal %d (by pid=%s uid=%s code=%s)",
+			  si->si_signo, dec2str(si->si_pid),
+			  dec2str(si->si_uid),
+			  lib_signal_code_to_str(si->si_signo, si->si_code));
+	}
 	io_loop_stop(ioloop);
 }
 
diff -r 9f3968f49ceb -r 5361cb6afe9e src/imap/main.c
--- a/src/imap/main.c	Wed Apr 01 12:52:46 2009 -0400
+++ b/src/imap/main.c	Wed Apr 01 13:13:04 2009 -0400
@@ -56,8 +56,12 @@ static void sig_die(const siginfo_t *si,
 {
 	/* warn about being killed because of some signal, except SIGINT (^C)
 	   which is too common at least while testing :) */
-	if (si->si_signo != SIGINT)
-		i_warning("Killed with signal %d", si->si_signo);
+	if (si->si_signo != SIGINT) {
+		i_warning("Killed with signal %d (by pid=%s uid=%s code=%s)",
+			  si->si_signo, dec2str(si->si_pid),
+			  dec2str(si->si_uid),
+			  lib_signal_code_to_str(si->si_signo, si->si_code));
+	}
 	io_loop_stop(ioloop);
 }
 
diff -r 9f3968f49ceb -r 5361cb6afe9e src/lib/lib-signals.c
--- a/src/lib/lib-signals.c	Wed Apr 01 12:52:46 2009 -0400
+++ b/src/lib/lib-signals.c	Wed Apr 01 13:13:04 2009 -0400
@@ -26,6 +26,42 @@ static int sig_pipe_fd[2] = { -1, -1 };
 
 static bool signals_initialized = FALSE;
 static struct io *io_sig = NULL;
+
+const char *lib_signal_code_to_str(int signo, int si_code)
+{
+	/* common */
+	switch (si_code) {
+	case SI_USER:
+		return "kill";
+#ifdef SI_KERNEL
+	case SI_KERNEL:
+		return "kernel";
+#endif
+	case SI_TIMER:
+		return "timer";
+	}
+
+	switch (signo) {
+	case SIGSEGV:
+		switch (si_code) {
+		case SEGV_MAPERR:
+			return "address not mapped";
+		case SEGV_ACCERR:
+			return "invalid permissions";
+		}
+		break;
+	case SIGBUS:
+		switch (si_code) {
+		case BUS_ADRALN:
+			return "invalid address alignment";
+		case BUS_ADRERR:
+			return "nonexistent physical address";
+		case BUS_OBJERR:
+			return "object-specific hardware error";
+		}
+	}
+	return t_strdup_printf("unknown %d", si_code);
+}
 
 static void sig_handler(int signo, siginfo_t *si, void *context ATTR_UNUSED)
 {
diff -r 9f3968f49ceb -r 5361cb6afe9e src/lib/lib-signals.h
--- a/src/lib/lib-signals.h	Wed Apr 01 12:52:46 2009 -0400
+++ b/src/lib/lib-signals.h	Wed Apr 01 13:13:04 2009 -0400
@@ -4,6 +4,9 @@
 #include <signal.h>
 
 typedef void signal_handler_t(const siginfo_t *si, void *context);
+
+/* Convert si_code to string */
+const char *lib_signal_code_to_str(int signo, int si_code);
 
 /* Set signal handler for specific signal. If delayed is TRUE, the handler
    will be called later, ie. not as a real signal handler. */
diff -r 9f3968f49ceb -r 5361cb6afe9e src/login-common/main.c
--- a/src/login-common/main.c	Wed Apr 01 12:52:46 2009 -0400
+++ b/src/login-common/main.c	Wed Apr 01 13:13:04 2009 -0400
@@ -71,8 +71,12 @@ static void sig_die(const siginfo_t *si,
 {
 	/* warn about being killed because of some signal, except SIGINT (^C)
 	   which is too common at least while testing :) */
-	if (si->si_signo != SIGINT)
-		i_warning("Killed with signal %d", si->si_signo);
+	if (si->si_signo != SIGINT) {
+		i_warning("Killed with signal %d (by pid=%s uid=%s code=%s)",
+			  si->si_signo, dec2str(si->si_pid),
+			  dec2str(si->si_uid),
+			  lib_signal_code_to_str(si->si_signo, si->si_code));
+	}
 	io_loop_stop(ioloop);
 }
 
diff -r 9f3968f49ceb -r 5361cb6afe9e src/master/main.c
--- a/src/master/main.c	Wed Apr 01 12:52:46 2009 -0400
+++ b/src/master/main.c	Wed Apr 01 13:13:04 2009 -0400
@@ -170,8 +170,12 @@ static void sig_die(const siginfo_t *si,
 {
 	/* warn about being killed because of some signal, except SIGINT (^C)
 	   which is too common at least while testing :) */
-	if (si->si_signo != SIGINT)
-		i_warning("Killed with signal %d", si->si_signo);
+	if (si->si_signo != SIGINT) {
+		i_warning("Killed with signal %d (by pid=%s uid=%s code=%s)",
+			  si->si_signo, dec2str(si->si_pid),
+			  dec2str(si->si_uid),
+			  lib_signal_code_to_str(si->si_signo, si->si_code));
+	}
 	io_loop_stop(ioloop);
 }
 
diff -r 9f3968f49ceb -r 5361cb6afe9e src/pop3/main.c
--- a/src/pop3/main.c	Wed Apr 01 12:52:46 2009 -0400
+++ b/src/pop3/main.c	Wed Apr 01 13:13:04 2009 -0400
@@ -56,8 +56,12 @@ static void sig_die(const siginfo_t *si,
 {
 	/* warn about being killed because of some signal, except SIGINT (^C)
 	   which is too common at least while testing :) */
-	if (si->si_signo != SIGINT)
-		i_warning("Killed with signal %d", si->si_signo);
+	if (si->si_signo != SIGINT) {
+		i_warning("Killed with signal %d (by pid=%s uid=%s code=%s)",
+			  si->si_signo, dec2str(si->si_pid),
+			  dec2str(si->si_uid),
+			  lib_signal_code_to_str(si->si_signo, si->si_code));
+	}
 	io_loop_stop(ioloop);
 }
 


More information about the dovecot-cvs mailing list