HP-UX Reference (11i v1 05/09) - 2 System Calls (vol 5)
f
fcntl(2) fcntl(2)
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_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_GETLK64 Value other than −1.
F_SETLK64 Value other than −1.
F_SETLKW64 Value other than −1.
Otherwise, a value of −1 is returned and errno is set to indicate the error.
ERRORS
fcntl() fails if any of the following conditions occur:
[EBADF] fildes is not a valid open file descriptor, or was not opened for reading when setting a
read lock or for writing when setting a write lock.
[EMFILE] cmd is F_DUPFD and the maximum number of file descriptors is currently open.
[EMFILE] cmd is F_SETLK or F_SETLKW, the type of lock is a read or write lock, and no more
file-locking headers are available (too many files have segments locked).
[EINVAL] cmd is F_DUPFD and arg is greater than or equal to the maximum number of file
descriptors.
[EINVAL] cmd is F_DUPFD and arg is negative.
[EINVAL] cmd is F_GETLK, F_SETLK,orF_SETLKW, and arg or the data it points to is not
valid, or fildes refers to a file that does not support locking.
[EINVAL] cmd is not a valid command.
[EINVAL] cmd is
F_SETFL and both O_NONBLOCK and O_NDELAY
are specified.
[EINTR] cmd is
F_SETLKW and the call was interrupted by a signal.
[EACCES] cmd is F_SETLK, the type of lock (l_type) is a read lock (
F_RDLCK ) or write lock
(
F_WRLCK ) and the segment of a file to be locked is already write-locked by another
process, or the type is a write lock ( F_WRLCK ) and the segment of a file to be locked
is already read- or write-locked by another process.
[ENOLCK] cmd is F_SETLK or F_SETLKW, the type of lock is a read or write lock, and no more
file-locking headers are available (too many files have segments locked), or no more
record locks are available (too many file segments locked).
[ENOLCK] cmd is F_SETLK or F_SETLKW , the type of lock (l_type) is a read lock
(F_RDLCK ) or write lock ( F_WRLCK ) and the file is an NFS file with access bits set
for enforcement mode.
[ENOLCK] cmd is F_GETLK, F_SETLK,orF_SETLKW, the file is an NFS file, and a system
error occurred on the remote node.
[EOVERFLOW]
cmd is F_GETLK and the blocking lock’s starting offset or length would not fit in the
caller’s structure.
[EDEADLK] cmd is F_SETLKW, when the lock is blocked by a lock from another process and sleep-
ing (waiting) for that lock to become free. This causes a deadlock situation.
HP-UX 11i Version 1: September 2005 − 3 − Hewlett-Packard Company Section 2−−67