-
-
Save anonymous/0ab40694144dfb612335 to your computer and use it in GitHub Desktop.
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/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