+ /* Try command line option path */
+ if (opt_sessiond_path != NULL) {
+ ret = access(opt_sessiond_path, F_OK | X_OK);
+ if (ret < 0) {
+ ERR("No such file: %s", opt_sessiond_path);
+ goto end;
+ }
+ pathname = opt_sessiond_path;
+ } else {
+ /* Try LTTNG_SESSIOND_PATH env variable */
+ pathname = strdup(getenv(LTTNG_SESSIOND_PATH_ENV));
+ }
+
+ /* Let's rock and roll */
+ if (pathname == NULL) {
+ ret = asprintf(&pathname, "ltt-sessiond");
+ if (ret < 0) {
+ goto end;
+ }
+ }
+
+ ret = spawn_sessiond(pathname);
+ free(pathname);
+ if (ret < 0) {
+ ERR("Problem occurs when starting %s", pathname);
+ goto end;
+ }
+ }
+
+end:
+ return ret;
+}
+
+/*
+ * set_signal_handler
+ *
+ * Setup signal handler for SIGCHLD and SIGTERM.
+ */
+static int set_signal_handler(void)
+{
+ int ret = 0;
+ struct sigaction sa;
+ sigset_t sigset;
+
+ if ((ret = sigemptyset(&sigset)) < 0) {
+ perror("sigemptyset");
+ goto end;