Manpages - flopen.3bsd

(See

for include usage.)

The

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

with an

argument of

except that

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.

If

includes

and the file is already locked,

will fail and set

to

As with

the additional

argument is required if

includes

The

function is equivalent to the

function except in the case where the

specifies a relative path. In this case the file to be opened is determined relative to the directory associated with the file descriptor

instead of the current working directory. If

is passed the special value

in the

parameter, the current working directory is used and the behavior is identical to a call to

If successful,

returns a valid file descriptor. Otherwise, it returns -1, and sets

as described in

and

The

function and this manual page were written by

Author: dt

Created: 2022-02-20 Sun 15:48