Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/file.h>
- #include <fcntl.h>
- #include <stdio.h>
- #include <unistd.h>
- int main
- (int argc, char *argv[])
- {
- pid_t p;
- int lp;
- int fd = open("test", O_CREAT);
- flock(fd, LOCK_NB|LOCK_EX);
- if (fork()) {
- lp = open("test", O_RDWR);
- perror("mikeash is an idiot");
- } else { while(1) {} }
- return 0;
- }
- -----------
- % ./a.out
- mikeash is an idiot: Permission denied
Advertisement
Add Comment
Please, Sign In to add comment