Skip to content

Instantly share code, notes, and snippets.

Created September 23, 2014 23:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/0ab40694144dfb612335 to your computer and use it in GitHub Desktop.
Save anonymous/0ab40694144dfb612335 to your computer and use it in GitHub Desktop.
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main() {
int fd;
struct flock lock, savelock;
fd = open("fake.dat", O_RDWR);
printf("fd = %d\n", fd);
lock.l_type = F_WRLCK;
lock.l_start = 0;
lock.l_whence = SEEK_SET;
lock.l_len = 0;
savelock = lock;
int code = fcntl(fd, F_GETLK, &lock);
printf("fcntl return code: %d\n", code);
exit(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment