Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

close(2)

exec(2)

open(2)

fcntl(5)



FCNTL(2)                 DOMAIN/IX SYS5                  FCNTL(2)



NAME
     fcntl - file control

USAGE
     #include <fcntl.h>

     int fcntl (fildes, cmd, arg)
     int fildes, cmd, arg;


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.

     Cmd is one of five valid commands; arg is a possible argu-
     ment to a cmd.

     The available commands 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 descrip-
               tors 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 remains open across execs; 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



Printed 12/4/86                                           FCNTL-1







FCNTL(2)                 DOMAIN/IX SYS5                  FCNTL(2)



               can be set.  (See fcntl(5)).

RETURN VALUE
     Upon successful completion, fcntl returns a value that
     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, the call returns -1 and sets errno to indicate
     the error.

ERRORS
     Fcntl fails if one or more of the following is true:

     [EBADF]    Fildes is not a valid open file descriptor.

     [EMFILE]   Cmd is F_DUPFD and the maximum number of open
                file descriptors has been exceeded.

     [EMFILE]   Cmd is F_DUPFD and arg is negative or greater
                than 20.

RELATED INFORMATION
     close(2), exec(2), open(2), fcntl(5)

























FCNTL-2                                           Printed 12/4/86





Typewritten Software • bear@typewritten.org • Edmonds, WA 98026