#include <libutil.h> int
flopen (const char *path int flags); int
flopen (const char *path int flags mode_t mode);
function opens or creates a file and acquires an exclusive lock on it.
It is essentially equivalent with calling
with the same parameters followed by
will attempt to detect and handle races that may occur between opening
/ creating the file and locking it.
Thus, it is well suited for opening lock files, PID files, spool
files, mailboxes and other kinds of files which are used for
synchronization between processes.
and the file is already locked,
will fail and set
argument is required if
returns a valid file descriptor.
Otherwise, it returns -1, and sets
as described in