X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Fmain.c;h=1e2a0831dc80187b4b581e72ef97a037762a3fa4;hp=1139df8b94fd26e256d10be10b6dda15965616b0;hb=7d8234d9e6f162ee642cdbec911f46c29b012c3d;hpb=fbf10601d3fca6076d257916e9bc38c81b3063e1 diff --git a/ltt-sessiond/main.c b/ltt-sessiond/main.c index 1139df8b9..1e2a0831d 100644 --- a/ltt-sessiond/main.c +++ b/ltt-sessiond/main.c @@ -2418,18 +2418,21 @@ end: } /* - * Check if the global socket is available. If yes, error is returned. + * Check if the global socket is available, and if a daemon is answering + * at the other side. If yes, error is returned. */ static int check_existing_daemon(void) { int ret; - ret = access(client_unix_sock_path, F_OK); - if (ret == 0) { - ret = access(apps_unix_sock_path, F_OK); - } - - return ret; + if (access(client_unix_sock_path, F_OK) < 0 && + access(apps_unix_sock_path, F_OK) < 0) + return 0; + /* Is there anybody out there ? */ + if (lttng_session_daemon_alive()) + return -EEXIST; + else + return 0; } /* @@ -2714,11 +2717,9 @@ int main(int argc, char **argv) DBG("Application socket path %s", apps_unix_sock_path); /* - * See if daemon already exist. If any of the two socket needed by the - * daemon are present, this test fails. However, if the daemon is killed - * with a SIGKILL, those unix socket must be unlinked by hand. + * See if daemon already exist. */ - if ((ret = check_existing_daemon()) == 0) { + if ((ret = check_existing_daemon()) < 0) { ERR("Already running daemon.\n"); /* * We do not goto exit because we must not cleanup()