#include "manage-apps.h"
#include "manage-kernel.h"
#include "modprobe.h"
+#include "ust-sigbus.h"
static const char *help_msg =
#ifdef LTTNG_EMBED_HELP
int ret = 0, c = 0, option_index = 0;
int orig_optopt = optopt, orig_optind = optind;
char *optstring;
- const char *config_path = NULL;
+ char *config_path = NULL;
optstring = utils_generate_optstring(long_options,
sizeof(long_options) / sizeof(struct option));
WARN("Getting '%s' argument from setuid/setgid binary refused for security reasons.",
"-f, --config");
} else {
+ free(config_path);
config_path = utils_expand_path(optarg);
if (!config_path) {
ERR("Failed to resolve path: %s", optarg);
}
end:
+ free(config_path);
free(optstring);
return ret;
}
ret = -EINVAL;
goto error;
}
- assert(path);
+ LTTNG_ASSERT(path);
DBG2("Creating consumer directory: %s", path);
* 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:
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;
}
}
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;
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;
}
struct lttng_triggers *triggers = NULL;
unsigned int trigger_count, i;
const struct lttng_credentials creds = {
- .uid = LTTNG_OPTIONAL_INIT_VALUE(0),
+ .uid = LTTNG_OPTIONAL_INIT_VALUE(0),
};
DBG("Unregistering all triggers");
}
trigger_status = lttng_triggers_get_count(triggers, &trigger_count);
- assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+ LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
for (i = 0; i < trigger_count; i++) {
uid_t trigger_owner;
const struct lttng_trigger *trigger =
lttng_triggers_get_at_index(triggers, i);
- assert(trigger);
+ LTTNG_ASSERT(trigger);
trigger_status = lttng_trigger_get_owner_uid(
trigger, &trigger_owner);
- assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+ LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ?