Unlink rundir files individually
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 9 Oct 2013 17:50:34 +0000 (13:50 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 9 Oct 2013 17:50:34 +0000 (13:50 -0400)
Cannot use rm -rf anymore since relayd now need to have the lttng rundir
available beyond the lifetime of sessiond.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/bin/lttng-sessiond/main.c

index 5ec39649969f9fef523e10b7e94896149d5812c1..de4736643010143c6af8c7a554f1682ddaebc651 100644 (file)
@@ -419,8 +419,8 @@ static void close_consumer_sockets(void)
 static void cleanup(void)
 {
        int ret;
-       char *cmd = NULL;
        struct ltt_session *sess, *stmp;
+       char path[PATH_MAX];
 
        DBG("Cleaning up");
 
@@ -441,18 +441,54 @@ static void cleanup(void)
                }
        }
 
-       DBG("Removing %s directory", rundir);
-       ret = asprintf(&cmd, "rm -rf %s", rundir);
-       if (ret < 0) {
-               ERR("asprintf failed. Something is really wrong!");
-       }
+       DBG("Removing sessiond and consumerd content of directory %s", rundir);
+
+       /* sessiond */
+       snprintf(path, PATH_MAX,
+               "%s/%s",
+               rundir, DEFAULT_LTTNG_SESSIOND_PIDFILE);
+       DBG("Removing %s", path);
+       (void) unlink(path);
+
+       /* kconsumerd */
+       snprintf(path, PATH_MAX,
+               DEFAULT_KCONSUMERD_ERR_SOCK_PATH,
+               rundir);
+       DBG("Removing %s", path);
+       (void) unlink(path);
+
+       snprintf(path, PATH_MAX,
+               DEFAULT_KCONSUMERD_PATH,
+               rundir);
+       DBG("Removing directory %s", path);
+       (void) rmdir(path);
+
+       /* ust consumerd 32 */
+       snprintf(path, PATH_MAX,
+               DEFAULT_USTCONSUMERD32_ERR_SOCK_PATH,
+               rundir);
+       DBG("Removing %s", path);
+       (void) unlink(path);
+
+       snprintf(path, PATH_MAX,
+               DEFAULT_USTCONSUMERD32_PATH,
+               rundir);
+       DBG("Removing directory %s", path);
+       (void) rmdir(path);
+
+       /* ust consumerd 64 */
+       snprintf(path, PATH_MAX,
+               DEFAULT_USTCONSUMERD64_ERR_SOCK_PATH,
+               rundir);
+       DBG("Removing %s", path);
+       (void) unlink(path);
+
+       snprintf(path, PATH_MAX,
+               DEFAULT_USTCONSUMERD64_PATH,
+               rundir);
+       DBG("Removing directory %s", path);
+       (void) rmdir(path);
 
-       /* Remove lttng run directory */
-       ret = system(cmd);
-       if (ret < 0) {
-               ERR("Unable to clean %s", rundir);
-       }
-       free(cmd);
        free(rundir);
 
        DBG("Cleaning up all sessions");
This page took 0.029945 seconds and 5 git commands to generate.