файловый контроль (file control)
Ошибки (Error)
The fcntl() function shall fail if:
EACCES
or EAGAIN
The cmd argument is F_SETLK; the type of lock (l_type) is
a shared (F_RDLCK) or exclusive (F_WRLCK) lock and the
segment of a file to be locked is already exclusive-locked
by another process, or the type is an exclusive lock and
some portion of the segment of a file to be locked is
already shared-locked or exclusive-locked by another
process.
EBADF
The fildes argument is not a valid open file descriptor,
or the argument cmd is F_SETLK or F_SETLKW, the type of
lock, l_type, is a shared lock (F_RDLCK), and fildes is
not a valid file descriptor open for reading, or the type
of lock, l_type, is an exclusive lock (F_WRLCK), and
fildes is not a valid file descriptor open for writing.
EINTR
The cmd argument is F_SETLKW and the function was
interrupted by a signal.
EINVAL
The cmd argument is invalid, or the cmd argument is
F_DUPFD or F_DUPFD_CLOEXEC and arg is negative or greater
than or equal to {OPEN_MAX}, or the cmd argument is
F_GETLK, F_SETLK, or F_SETLKW and the data pointed to by
arg is not valid, or fildes refers to a file that does not
support locking.
EMFILE
The argument cmd is F_DUPFD or F_DUPFD_CLOEXEC and all
file descriptors available to the process are currently
open, or no file descriptors greater than or equal to arg
are available.
ENOLCK
The argument cmd is F_SETLK or F_SETLKW and satisfying the
lock or unlock request would result in the number of
locked regions in the system exceeding a system-imposed
limit.
EOVERFLOW
One of the values to be returned cannot be represented
correctly.
EOVERFLOW
The cmd argument is F_GETLK, F_SETLK, or F_SETLKW and the
smallest or, if l_len is non-zero, the largest offset of
any byte in the requested segment cannot be represented
correctly in an object of type off_t
.
ESRCH
The cmd argument is F_SETOWN and no process or process
group can be found corresponding to that specified by arg.
The fcntl() function may fail if:
EDEADLK
The cmd argument is F_SETLKW, the lock is blocked by a
lock from another process, and putting the calling process
to sleep to wait for that lock to become free would cause
a deadlock.
EINVAL
The cmd argument is F_SETOWN and the value of the argument
is not valid as a process or process group identifier.
EPERM
The cmd argument is F_SETOWN and the calling process does
not have permission to send a SIGURG signal to any process
specified by arg.
The following sections are informative.