]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
When a process is killed, show the signal code and the sending process's pid and...
authorTimo Sirainen <tss@iki.fi>
Wed, 1 Apr 2009 17:13:04 +0000 (13:13 -0400)
committerTimo Sirainen <tss@iki.fi>
Wed, 1 Apr 2009 17:13:04 +0000 (13:13 -0400)
--HG--
branch : HEAD

src/auth/main.c
src/deliver/deliver.c
src/dict/main.c
src/imap/main.c
src/lib/lib-signals.c
src/lib/lib-signals.h
src/login-common/main.c
src/master/main.c
src/pop3/main.c

index 7bc8e313950d87e7d78949e7b55a76942c8627aa..af40acbe36d9029499ae1a738edc74a5de4e5adc 100644 (file)
@@ -42,8 +42,12 @@ static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
 {
        /* 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);
 }
 
index 619874ef25eada33c66004ba2e4f9257876e578b..55adc44d972bba58cb5b5fbb7f67d67a01736955 100644 (file)
@@ -74,8 +74,12 @@ static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
 {
        /* 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);
 }
 
index cca7894312a44b58ec07a9f44fa9b30afd5d6698..03151006f3b0a9cf2689d5aa355adf2e63c5552e 100644 (file)
@@ -27,8 +27,12 @@ static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
 {
        /* 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);
 }
 
index a154097c94b2ae716967308e6708cc8d00329ce2..af4815067d7836bab9e6c3e912ec83c045215cb6 100644 (file)
@@ -56,8 +56,12 @@ static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
 {
        /* 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);
 }
 
index 787b4f8a308190569e680eec506cb83ba463df19..e96cb9b39faab86df9d6e8694dae487f7aa87f86 100644 (file)
@@ -27,6 +27,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)
 {
        struct signal_handler *h;
index 59ff38c1f26467eaf821a1ba5e4d7d658d3f3a4c..273d7b8ed422fa62421e7db603d6d7e9d2ec563d 100644 (file)
@@ -5,6 +5,9 @@
 
 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. */
 void lib_signals_set_handler(int signo, bool delayed,
index f88924ff0b520d4198d5afd825004a3dba22136a..03598aaf05f69b7ac7cbbeb799ccf87ceae6f8e0 100644 (file)
@@ -71,8 +71,12 @@ static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
 {
        /* 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);
 }
 
index a9aff73b1ea81a7eb0c267372dfe78a7bce70949..f431a7e7cffa38e6415dbf279d6e638ad2bf5085 100644 (file)
@@ -170,8 +170,12 @@ static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
 {
        /* 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);
 }
 
index bcbf088d92d268e40ee989f48c8cd34e905cedb6..c0bb229fca8ac1cd0e9924c0290676cb49553b2a 100644 (file)
@@ -56,8 +56,12 @@ static void sig_die(const siginfo_t *si, void *context ATTR_UNUSED)
 {
        /* 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);
 }