HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
f
fcntl(2) fcntl(2)
NAME
fcntl - file control
SYNOPSIS
#include <fcntl.h>
int fcntl(int fildes, int cmd, ... /* arg */);
Remarks
The ANSI C ", ..." construct denotes a variable length argument list whose optional [or required]
members are given in the associated comment (/* */).
DESCRIPTION
fcntl() provides for control over open files. fildes is an open file descriptor.
The following are possible values for the cmd argument:
F_DUPFD Return a new file descriptor having the following characteristics:
• Lowest numbered available file descriptor greater than or equal to the third
argument, arg, taken as an integer of type
int.
• Same open file (or pipe) as the original file.
• Same file pointer as the original file (that is, both file descriptors share one
file pointer).
• Same access mode (read, write or read/write).
• Same file status flags (that is, 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 exec(2) system calls.
F_GETFD Get the close-on-exec flag associated with the file descriptor fildes. If the low-order bit
is
0 the file will remain open across exec(2), otherwise the file will be closed upon exe-
cution of exec(2).
F_SETFD Set the close-on-exec flag associated with fildes to the low-order bit of the third argu-
ment, arg, taken as an integer of type
int (see F_GETFD).
F_GETFL Get file status flags and access modes; see fcntl(5).
F_SETFL Set file status flags to the third argument, arg, taken as an integer of type
int. Only
certain flags can be set; see fcntl(5). It is not possible to set both
O_NDELAY
and
O_NONBLOCK.
F_GETLK Get the first lock that blocks the lock described by the variable of type struct
flock
pointed to by the third argument, arg, taken as a pointer to type struct
flock
. The information retrieved overwrites the information passed to fcntl()
in the flock structure. If no lock is found that would prevent this lock from being
created, the structure is passed back unchanged, except that the lock type is set to
F_UNLCK.
F_SETLK Set or clear a file segment lock according to the variable of type struct flock
pointed to by the third argument, arg, taken as a pointer to type struct flock
(see fcntl(5)). The cmd F_SETLK is used to establish read (F_RDLCK ) and write
(F_WRLCK ) locks, as well as to remove either type of lock (F_UNLCK ). If a read or
write lock cannot be set,
fcntl() returns immediately with an error value of −1.
F_SETLKW This cmd is the same as F_SETLK except that if a read or write lock is blocked by
other locks, the process will sleep until the segment is free to be locked.
F_GETOWN If fildes refers to a socket, fcntl() returns the process or process group ID
specified to receive SIGURG signals when out-of-band data is available. Positive
values indicate a process ID; negative values, other than -1, indicate a process group
ID.
F_SETOWN If fildes refers to a socket, fcntl() sets the process or process group ID specified to
receive SIGURG signals when out-of-band data is available, using the value of the
Section 2−−62 − 1 − HP-UX Release 11i: December 2000
___
___