fcntl.2 (2011 03)

f
fcntl(2) fcntl(2)
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.
F_UNSHARE 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:
[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 seg-
ment of a file to be locked is already read- or write-locked by another process.
[EAGAIN] cmd is
F_SETLK or F_SETLKW, and the file is mapped in to virtual memory
using the mmap() system call (see mmap(2)).
[EAGAIN] cmd is
F_SHARE and f_access conflicts with an existing f_deny share
reservation.
[EAGAIN] cmd is
F_SETOPLOCK, and this request conflicts with an existing byte lock or
share reservation.
[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.
[EBADF] cmd arg is
F_SHARE, and the f_access share reservation is for read or
write access, and the file descriptor is not a valid file descriptor open for read-
ing.
[EDEADLK] cmd is
F_SETLKW, and the lock is in a deadlock situation. The deadlock
situation occurs when the lock is blocked by a lock from another process and
the lock sleeps and waits for that other lock to become free.
6 Hewlett-Packard Company 6 HP-UX 11i Version 3: March 2011