|
NAMEflopen , flopenat —
Reliably open and lock a file
LIBRARYSystem Utilities Library (libutil, -lutil)SYNOPSIS#include <sys/fcntl.h>
#include <libutil.h>
int
int
int
int
DESCRIPTIONTheflopen () function opens or creates a file and
acquires an exclusive lock on it. It is essentially equivalent with calling
open () with the same parameters followed by
flock () with an operation
argument of LOCK_EX , except that
flopen () 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 flags includes
As with The RETURN VALUESIf successful,flopen () returns a valid file descriptor.
Otherwise, it returns -1, and sets errno as described in
flock(2)
and
open(2).
SEE ALSOerrno(2), flock(2), open(2)AUTHORSTheflopen function and this manual page were written by
Dag-Erling Smørgrav
<des@FreeBSD.org>.
Visit the GSP FreeBSD Man Page Interface. |