Add with-sessiond-bin configure option
[lttng-tools.git] / src / bin / lttng / lttng.c
index be673f94f2d0ab552c4f9daa3f90bff70637b2d1..d3aaa8424683b58c189d2c8f9afc894f5d937bf2 100644 (file)
@@ -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;
This page took 0.023385 seconds and 4 git commands to generate.