projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Port: cleanup and portability fix to configure.ac
[lttng-tools.git]
/
src
/
common
/
utils.c
diff --git
a/src/common/utils.c
b/src/common/utils.c
index ca4eb44481c7d3e7fc90500c91112f50aaacef09..52fb25dbe7202a3af44d1548ea1b021b2ad7ee65 100644
(file)
--- a/
src/common/utils.c
+++ b/
src/common/utils.c
@@
-504,11
+504,13
@@
int utils_create_lock_file(const char *filepath)
{
int ret;
int fd;
{
int ret;
int fd;
+ struct flock lock;
assert(filepath);
assert(filepath);
- fd = open(filepath, O_CREAT,
- O_WRONLY | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP);
+ 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);
ret = -1;
if (fd < 0) {
PERROR("open lock file %s", filepath);
ret = -1;
@@
-520,8
+522,12
@@
int utils_create_lock_file(const char *filepath)
* already a process using the same lock file running
* and we should exit.
*/
* already a process using the same lock file running
* and we should exit.
*/
- ret = flock(fd, LOCK_EX | LOCK_NB);
- if (ret) {
+ 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)) {
ERR("Could not get lock file %s, another instance is running.",
filepath);
if (close(fd)) {
This page took
0.022961 seconds
and
4
git commands to generate.