Fix: syscall event rule: emission sites not compared in is_equal
[lttng-tools.git] / src / common / utils.cpp
index 831926aab16c48656082113a984386d530be3203..62c9c22d52686e442edad15ce3a4a17a8edb0a75 100644 (file)
@@ -254,49 +254,6 @@ error:
        return ret;
 }
 
-/*
- * Create lock file to the given path and filename.
- * Returns the associated file descriptor, -1 on error.
- */
-int utils_create_lock_file(const char *filepath)
-{
-       int ret;
-       int fd;
-       struct flock lock;
-
-       LTTNG_ASSERT(filepath);
-
-       memset(&lock, 0, sizeof(lock));
-       fd = open(filepath, O_CREAT | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
-       if (fd < 0) {
-               PERROR("open lock file %s", filepath);
-               fd = -1;
-               goto error;
-       }
-
-       /*
-        * Attempt to lock the file. If this fails, there is
-        * already a process using the same lock file running
-        * and we should exit.
-        */
-       lock.l_whence = SEEK_SET;
-       lock.l_type = F_WRLCK;
-
-       ret = fcntl(fd, F_SETLK, &lock);
-       if (ret == -1) {
-               PERROR("fcntl lock file");
-               ERR("Could not get lock file %s, another instance is running.", filepath);
-               if (close(fd)) {
-                       PERROR("close lock file");
-               }
-               fd = ret;
-               goto error;
-       }
-
-error:
-       return fd;
-}
-
 /*
  * Create directory using the given path and mode.
  *
@@ -1020,10 +977,23 @@ static const char *get_man_bin_path()
        return DEFAULT_MAN_BIN_PATH;
 }
 
+static const char *get_manpath()
+{
+       char *manpath = lttng_secure_getenv(DEFAULT_MANPATH);
+
+       if (manpath) {
+               return manpath;
+       }
+
+       /* As defined during configuration. */
+       return MANPATH;
+}
+
 int utils_show_help(int section, const char *page_name, const char *help_msg)
 {
        char section_string[8];
        const char *man_bin_path = get_man_bin_path();
+       const char *manpath = get_manpath();
        int ret = 0;
 
        if (help_msg) {
@@ -1032,7 +1002,7 @@ int utils_show_help(int section, const char *page_name, const char *help_msg)
        }
 
        /* Section integer -> section string */
-       ret = sprintf(section_string, "%d", section);
+       ret = snprintf(section_string, sizeof(section_string), "%d", section);
        LTTNG_ASSERT(ret > 0 && ret < 8);
 
        /*
@@ -1042,7 +1012,7 @@ int utils_show_help(int section, const char *page_name, const char *help_msg)
         * be installed outside /usr, in which case its man pages are
         * not located in the default /usr/share/man directory.
         */
-       ret = execlp(man_bin_path, "man", "-M", MANPATH, section_string, page_name, NULL);
+       ret = execlp(man_bin_path, "man", "-M", manpath, section_string, page_name, NULL);
 
 end:
        return ret;
This page took 0.026695 seconds and 4 git commands to generate.