Skip to content

Instantly share code, notes, and snippets.

@zanchey
Created July 1, 2015 01:51
Show Gist options
  • Save zanchey/64949b7e728f3fe04d9a to your computer and use it in GitHub Desktop.
Save zanchey/64949b7e728f3fe04d9a to your computer and use it in GitHub Desktop.
test flock on NFS
#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