X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Futils.cpp;h=b4b7f749f1ef1a6e5286225437f639d01f2966d2;hp=7cd61c049c3ffeae0b7bdcf74dc5a0eb9a6c58da;hb=HEAD;hpb=ef4a570db1fbc6ffa5f645e76c4cf25e8098aee1 diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 7cd61c049..62c9c22d5 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -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. *