Use MT-safe strtok_r in spawn viewer library helper
[lttng-tools.git] / src / common / spawn-viewer.c
index 26fe9199faab60fbbae724ebf3dd7922edb2a73f..1d668157f729e11e47f5fb199976c0b0a0b771d1 100644 (file)
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <unistd.h>
-#include <errno.h>
 
 #include <lttng/constant.h>
 
+#include <common/compat/errno.h>
 #include "error.h"
 #include "macros.h"
 #include "spawn-viewer.h"
@@ -69,7 +69,7 @@ static char **alloc_argv_from_user_opts(char *opts, const char *trace_path)
 {
        int i = 0, ignore_space = 0;
        unsigned int num_opts = 1;
-       char **argv, *token = opts;
+       char **argv, *token = opts, *saveptr;
 
        /* Count number of arguments. */
        do {
@@ -91,13 +91,13 @@ static char **alloc_argv_from_user_opts(char *opts, const char *trace_path)
                goto error;
        }
 
-       token = strtok(opts, " ");
+       token = strtok_r(opts, " ", &saveptr);
        while (token != NULL) {
                argv[i] = strdup(token);
                if (argv[i] == NULL) {
                        goto error;
                }
-               token = strtok(NULL, " ");
+               token = strtok_r(NULL, " ", &saveptr);
                i++;
        }
 
This page took 0.023651 seconds and 4 git commands to generate.