← BYTES
Unix IPC·Starter·Ref: 15.1.13
What is the basic purpose of flock() (an advisory file lock)?
Have a question about this video? Mention reference 15.1.13 when you contact us.
a.It encrypts a file's contents
b.It lets cooperating processes coordinate access to a shared file by voluntarily requesting an exclusive or shared lock on it -- 'advisory' meaning the kernel only enforces it against other processes that also check the lock
c.It permanently deletes a file
d.It compresses a file to save disk space
flock() provides advisory locking: a process can request an exclusive (one writer) or shared (many readers) lock on a whole file, and the kernel tracks and enforces that lock against OTHER PROCESSES THAT ALSO CALL flock() -- but a process that simply opens and writes the file directly, ignoring the lock, is not blocked by it at all. This makes it a cooperative IPC mechanism for well-behaved processes, not a security boundary.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES15113#UnixIPC