From d89b35e6826ecaccc4d2f421c8013f35ec5854a0 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 22 Apr 2013 08:42:19 +0000 Subject: [PATCH] Use lockf which is more portable than flock, from Dagobert Michelsen. --- client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.c b/client.c index 70e7f1ec..0c8657eb 100644 --- a/client.c +++ b/client.c @@ -78,8 +78,8 @@ client_get_lock(char *lockfile) if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1) fatal("open failed"); - if (flock(lockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) { - while (flock(lockfd, LOCK_EX) == -1 && errno == EINTR) + if (lockf(lockfd, F_TLOCK, 0) == -1 && errno == EAGAIN) { + while (lockf(lockfd, F_LOCK, 0) == -1 && errno == EINTR) /* nothing */; close(lockfd); return (-1);