{
/* 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);
}
{
/* 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);
}
{
/* 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);
}
{
/* 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);
}
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;
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,
{
/* 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);
}
{
/* 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);
}
{
/* 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);
}