X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fmain.c;fp=src%2Fbin%2Flttng-sessiond%2Fmain.c;h=ee4d0c78ec499800cd5e149c95a02afa4f3a53e4;hp=1174162aa9ac8df25b4dcfc23994a95ac09e50bb;hb=881fc67f7002469477a5ad00e67a8077db6c0514;hpb=4243641037bcc27e6338674a5c39699a22347654 diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 1174162aa..ee4d0c78e 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -75,6 +75,7 @@ #include "manage-apps.h" #include "manage-kernel.h" #include "modprobe.h" +#include "ust-sigbus.h" static const char *help_msg = #ifdef LTTNG_EMBED_HELP @@ -1170,7 +1171,7 @@ error: * Simply stop all worker threads, leaving main() return gracefully after * joining all threads and calling cleanup(). */ -static void sighandler(int sig) +static void sighandler(int sig, siginfo_t *siginfo, void *arg) { switch (sig) { case SIGINT: @@ -1184,6 +1185,23 @@ static void sighandler(int sig) case SIGUSR1: CMM_STORE_SHARED(recv_child_signal, 1); break; + case SIGBUS: + { + int write_ret; + const char msg[] = "Received SIGBUS, aborting program.\n"; + + lttng_ust_handle_sigbus(siginfo->si_addr); + /* + * If ustctl did not catch this signal (triggering a + * siglongjmp), abort the program. Otherwise, the execution + * will resume from the ust-ctl call which caused this error. + * + * The return value is ignored since the program aborts anyhow. + */ + write_ret = write(STDERR_FILENO, msg, sizeof(msg)); + (void) write_ret; + abort(); + } default: break; } @@ -1205,9 +1223,9 @@ static int set_signal_handler(void) } sa.sa_mask = sigset; - sa.sa_flags = 0; + sa.sa_flags = SA_SIGINFO; - sa.sa_handler = sighandler; + sa.sa_sigaction = sighandler; if ((ret = sigaction(SIGTERM, &sa, NULL)) < 0) { PERROR("sigaction"); return ret; @@ -1223,13 +1241,19 @@ static int set_signal_handler(void) return ret; } + if ((ret = sigaction(SIGBUS, &sa, NULL)) < 0) { + PERROR("sigaction"); + return ret; + } + + sa.sa_flags = 0; sa.sa_handler = SIG_IGN; if ((ret = sigaction(SIGPIPE, &sa, NULL)) < 0) { PERROR("sigaction"); return ret; } - DBG("Signal handler set for SIGTERM, SIGUSR1, SIGPIPE and SIGINT"); + DBG("Signal handler set for SIGTERM, SIGUSR1, SIGPIPE, SIGINT, and SIGBUS"); return ret; }