diff options
Diffstat (limited to 'lock_exnb.c')
-rw-r--r-- | lock_exnb.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lock_exnb.c b/lock_exnb.c new file mode 100644 index 0000000..9ec2b9c --- /dev/null +++ b/lock_exnb.c | |||
@@ -0,0 +1,13 @@ | |||
1 | /* Public domain. */ | ||
2 | |||
3 | #include <sys/types.h> | ||
4 | #include <sys/file.h> | ||
5 | #include <fcntl.h> | ||
6 | #include "hasflock.h" | ||
7 | #include "lock.h" | ||
8 | |||
9 | #ifdef HASFLOCK | ||
10 | int lock_exnb(int fd) { return flock(fd,LOCK_EX | LOCK_NB); } | ||
11 | #else | ||
12 | int lock_exnb(int fd) { return lockf(fd,2,0); } | ||
13 | #endif | ||