System Interface Guide

Setting a File Lock

To lock an entire file, set the offset to zero and set the size to zero.

There are several ways to set a lock on a file. Choice of method depends on how the lock interacts with the rest of the program, performance, and portability. This example uses the POSIX standard-compatible fcntl(2) function. It tries to lock a file until one of the following happens: