-
-
Save Noitidart/aa0db8492f970fd685c0 to your computer and use it in GitHub Desktop.
lock.c - Testing fcntl from c writen by nixeagle
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; | |
printf("F_GETLK: %d\n", F_GETLK); | |
printf("F_WRLCK: %d\n", F_WRLCK); | |
printf("F_RDLCK: %d\n", F_RDLCK); | |
printf("F_UNLCK: %d\n", F_UNLCK); | |
printf("SEEK_SET: %d\n", SEEK_SET); | |
printf("SEEK_CUR: %d\n", SEEK_CUR); | |
printf("SEEK_END: %d\n", SEEK_END); | |
fd = open("/home/noi/.mozilla/firefox/b51cfon3.Unnamed Profile 1/.parentlock", 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 codeee: %d\n", code); | |
printf("lock.l_pid: %d\n", lock.l_pid); | |
printf("lock.l_type: %d\n", lock.l_type); | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
README
Rev1
fcntl
andopen
Rev2
Rev3
fcntl