.\" Copyright (c) 1983 The Regents of the University of California.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)fcntl.2 6.7 (Berkeley) 3/10/91
.Fd #include <sys/fcntl.h>
.Fn fcntl "int fd" "int cmd" "int arg"
provides for control over descriptors.
is a descriptor to be operated on by
.Bl -tag -width F_GETOWNX
Return a new descriptor as follows:
.Bl -bullet -compact -offset 4n
Lowest numbered available descriptor greater than or equal to
Same object references as the original descriptor.
New descriptor shares the same file offset if the object
Same access mode (read, write or read/write).
Same file status flags (i.e., both file descriptors
share the same file status flags).
The close-on-exec flag associated with the new file descriptor
is set to remain open across
Get the close-on-exec flag associated with the file descriptor
If the low-order bit of the returned value is 0,
the file will remain open across
otherwise the file will be closed upon execution of
Set the close-on-exec flag associated with
Get descriptor status flags, as described below
Set descriptor status flags to
Get the process ID or process group
signals; process groups are returned
Set the process or process group
process groups are specified by supplying
is interpreted as a process ID.
.Bl -tag -width F_GETOWNX
Non-blocking I/O; if no data is available to a
the read or write call returns -1 with the error
Force each write to append at the end of file;
signal to be sent to the process group
when I/O is possible, e.g.,
upon availability of data to be read.
Upon successful completion, the value returned depends on
.Bl -tag -width F_GETOWNX -offset indent
Value of flag (only the low-order bit is defined).
Value of file descriptor owner.
Otherwise, a value of -1 is returned and
is set to indicate the error.
is not a valid open file descriptor.
and the maximum allowed number of file descriptors are currently
is negative or greater than the maximum allowable number
the process ID given as argument is not in use.
The asynchronous I/O facilities of
are currently available only for tty and socket operations.
function call appeared in