Skip to content

Instantly share code, notes, and snippets.

@Noitidart
Forked from anonymous/gist:0ab40694144dfb612335
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Noitidart/aa0db8492f970fd685c0 to your computer and use it in GitHub Desktop.
Save Noitidart/aa0db8492f970fd685c0 to your computer and use it in GitHub Desktop.
lock.c - Testing fcntl from c writen by nixeagle
#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);
}
@Noitidart
Copy link
Author

README

Rev1

Rev2

  • Made public

Rev3

  • My version to dump constant values for use with fcntl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment