FCNTL(2) HP Integral PC FCNTL(2) FCNTL(2) HP Integral PC FCNTL(2) FCNTL(2) HP Integral PC FCNTL(2) FCNTL(2) HP Integral PC FCNTL(2) NAME NAME NAME NAME fcntl - file control SYNOPSIS SYNOPSIS SYNOPSIS SYNOPSIS #include int fcntl (fildes, cmd, arg) int fildes, cmd, arg; DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION Fcntl provides for control over open files. Fildes is an open file descriptor obtained from a creat , open , dup , fcntl , or pipe system call. The cmd s available are: F_DUPFD- Return a new file descriptor as follows: Lowest numbered available file descriptor greater than or equal to arg . Same open file (or pipe) as the original file. Same file pointer as the original file (i.e., both file descriptors share one file pointer). 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 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 , otherwise the file will be closed upon execution of exec . F_SETFD- Set the close-on-exec flag associated with fildes to the low-order bit of arg ( 0 or 1 as above). F_GETFL- Get file status flags. F_SETFL- Set file status flags to arg . Only certain flags can be set; see fcntl (7). Fcntl will fail if one or more of the following are true: Fildes is not a valid open file descriptor. [EBADF] Hewlett-Packard - 1 - (printed 12/12/84) FCNTL(2) HP Integral PC FCNTL(2) FCNTL(2) HP Integral PC FCNTL(2) FCNTL(2) HP Integral PC FCNTL(2) FCNTL(2) HP Integral PC FCNTL(2) Cmd is F_DUPFD - and 20 file descriptors are currently open. [EMFILE] Cmd is F_DUPFD - and arg is negative or greater than 20. [EINVAL] RETURN VALUE RETURN VALUE RETURN VALUE RETURN VALUE Upon successful completion, the value returned depends on cmd as follows: F_DUPFD- A new file descriptor. F_GETFD- Value of flag (only the low-order bit is defined). F_SETFD- Value other than -1. F_GETFL- Value of file flags. F_SETFL- Value other than -1. Otherwise, a value of -1 is returned and errno is set to indicate the error. SEE ALSO SEE ALSO SEE ALSO SEE ALSO close(2), exec(2), open(2), fcntl(7). Hewlett-Packard - 2 - (printed 12/12/84)