X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Futils.c;fp=src%2Fcommon%2Futils.c;h=a2b86d5c320af65a1b4f0b06aef730139abb051b;hb=cf7e5f0026e05a5044d079f5fcc6264df29828fd;hp=8b2e0063c28d8bbc5570dc319c9121ea04d8af44;hpb=c03a0ff462df61b6d38fb112aa846356d4aa6c0f;p=lttng-tools.git diff --git a/src/common/utils.c b/src/common/utils.c index 8b2e0063c..a2b86d5c3 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -264,52 +264,6 @@ error: return ret; } -/* - * Create lock file to the given path and filename. - * Returns the associated file descriptor, -1 on error. - */ -LTTNG_HIDDEN -int utils_create_lock_file(const char *filepath) -{ - int ret; - int fd; - struct flock lock; - - 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. *