Created
July 1, 2015 01:51
-
-
Save zanchey/64949b7e728f3fe04d9a to your computer and use it in GitHub Desktop.
test flock on NFS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/file.h> | |
#include <stdio.h> | |
int main() | |
{ | |
int fd = open("./_testlockfile", O_RDONLY | O_CREAT, 0644); | |
if (fd < 0) | |
{ | |
perror("open"); | |
return 1; | |
} | |
int res = flock(fd, LOCK_EX); | |
if (res != 0) | |
{ | |
perror("flock"); | |
return 1; | |
} | |
else | |
{ | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment