From: Mathieu Desnoyers Date: Wed, 9 Oct 2013 17:50:34 +0000 (-0400) Subject: Unlink rundir files individually X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=8c6c56c2c6577c540786b341e5334f676c12d43a Unlink rundir files individually 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 --- diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 5ec396499..de4736643 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -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");