X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng%2Flttng.c;h=d3aaa8424683b58c189d2c8f9afc894f5d937bf2;hp=be673f94f2d0ab552c4f9daa3f90bff70637b2d1;hb=b8ec3da8333ea4489eaee6b3060287adc666a729;hpb=c2a79a67ba772bb10e5df8081b4830fdab88a99c diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index be673f94f..d3aaa8424 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -346,39 +346,43 @@ end: static int check_sessiond(void) { int ret; - char *pathname = NULL, *alloc_pathname = NULL; + char *pathname = NULL; ret = lttng_session_daemon_alive(); if (ret == 0) { /* not alive */ /* 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 or access denied: %s", opt_sessiond_path); - goto end; - } - pathname = opt_sessiond_path; - } else { - /* Try LTTNG_SESSIOND_PATH env variable */ + pathname = opt_sessiond_path; + + /* Try LTTNG_SESSIOND_PATH env variable */ + if (pathname == NULL) { pathname = getenv(DEFAULT_SESSIOND_PATH_ENV); } - /* Let's rock and roll */ + /* Try with configured path */ if (pathname == NULL) { - ret = asprintf(&alloc_pathname, INSTALL_BIN_PATH "/lttng-sessiond"); - if (ret < 0) { - perror("asprintf spawn sessiond"); - goto end; + if (CONFIG_SESSIOND_BIN[0] != '\0') { + pathname = CONFIG_SESSIOND_BIN; } - pathname = alloc_pathname; + } + + /* Let's rock and roll while trying the default path */ + if (pathname == NULL) { + pathname = INSTALL_BIN_PATH "/lttng-sessiond"; + } + + DBG("Session daemon at: %s", pathname); + + /* Check existence and permissions */ + ret = access(pathname, F_OK | X_OK); + if (ret < 0) { + ERR("No such file or access denied: %s", pathname); + goto end; } ret = spawn_sessiond(pathname); if (ret < 0) { ERR("Problem occurred when starting %s", pathname); } - - free(alloc_pathname); } end: return ret;