1. flock fcntl() F_SETLK ( ):
..
struct flock fi;
fd=open(file, O_RDWR);
fi.l_type = F_WRLCK;
fi.l_whence = SEEK_SET;
fi.l_start = 0;
fi.l_len = 64;
off = 0;
while (fcntl(fd, F_SETLK &fi)== -1)
{ fcntl(fd, F_GETLK & fi);
...
printf(" %i - %i %i\n", off, off+64
fi.l_pid);
}
, fcntl -1. F_GETLK , , .
2. , , fctnl() F_SETLK (, ?) l_type = F_UNLCK:
fi.l_type = F_UNLCK;
if (fcntl(fd, F_SETLK &fi)== -1)
printf(" \n");
5.
1. , . ' . , .
2. , . ' . 0, , -1
3. , . ' . , -1 .
4. , . . , .
5. , , ? ' . 0, , -1 .
6. , , (S_ISUID)? . 0, , -1 .
7. , , ? . 0, , -1 .
8. , . .
9. , , . , , , . , .
10. , , , . .
11. , , : . .
12. , O_NONBLOCK . , .