summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2013-04-22 08:42:20 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2013-04-22 08:42:20 +0000
commit188240261a2d2b210cc306b5c25b8f965dc159fd (patch)
tree2e7f5bc0c7d14f7fcca35387dd35209e83d93d50
parent46b39f15dded66b75b4f15a15247d9052cfc8eb3 (diff)
Use lockf which is more portable than flock, from Dagobert Michelsen.
-rw-r--r--usr.bin/tmux/client.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c
index 6f58f16f832..6cd76bd3961 100644
--- a/usr.bin/tmux/client.c
+++ b/usr.bin/tmux/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.65 2013/03/25 11:38:57 nicm Exp $ */
+/* $OpenBSD: client.c,v 1.66 2013/04/22 08:42:19 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);