HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)

f
fcntl(2) fcntl(2)
Application Usage
Because in the future the external variable errno
will be set to [EAGAIN] rather than [EACCES] when a
section of a file is already locked by another process, portable application programs should expect and test
for either value. For example:
flk->l_type = F_RDLCK;
if (fcntl(fd, F_SETLK, flk) == -1)
if ((errno == EACCES) || (errno == EAGAIN))
/*
* section locked by another process,
* check for either EAGAIN or EACCES
* due to different implementations
*/
else if ...
/*
* check for other errors
*/
NETWORKING FEATURES
NFS
The advisory record-locking capabilities of
fcntl() are implemented throughout the network by the "net-
work lock daemon" (see lockd(1M)). If the file server crashes and is rebooted, the lock daemon attempts to
recover all locks associated with the crashed server. If a lock cannot be reclaimed, the process that held
the lock is issued a
SIGLOST signal.
Record locking, as implemented for NFS files, is only advisory.
RETURN VALUE
Upon successful completion, the value returned depends on cmd as follows:
F_ADVISE Value of requested hint operation.
F_DUPFD A new file descriptor.
F_GETFD Value of close-on-exec flag (only the low-order bit is defined).
F_SETFD Value other than 1.
F_GETFL Value of file status flags and access modes.
F_SETFL Value other than 1.
F_GETLK Value other than 1.
F_SETLK Value other than 1.
F_SETLKW Value other than 1.
F_SETOPLOCK Value other than 1.
F_SETOPLOCKW Value other than 1.
F_HAVE_OPLOCK Value other than 1.
F_REMOVE_OPLOCK Value other than 1.
F_GETLK64 Value other than 1.
F_SETLK64 Value other than 1.
F_SETLKW64 Value other than 1.
F_GETOWN Value of process or process group ID specified to receive SIGURG signals
when out-of-band data is available.
F_SETOWN Value other than 1.
F_GETTIMES Value other than 1.
F_SETTIMES Value other than 1.
F_SHARE Value other than 1.
HP-UX 11i Version 3: February 2007 5 Hewlett-Packard Company 107