(libc.info.gz) Control Operations

Info Catalog (libc.info.gz) Asynchronous I/O (libc.info.gz) Low-Level I/O (libc.info.gz) Duplicating Descriptors
 
 13.11 Control Operations on Files
 =================================
 
 This section describes how you can perform various other operations on
 file descriptors, such as inquiring about or setting flags describing
 the status of the file descriptor, manipulating record locks, and the
 like.  All of these operations are performed by the function 'fcntl'.
 
    The second argument to the 'fcntl' function is a command that
 specifies which operation to perform.  The function and macros that name
 various flags that are used with it are declared in the header file
 'fcntl.h'.  Many of these flags are also used by the 'open' function;
 see  Opening and Closing Files.
 
  -- Function: int fcntl (int FILEDES, int COMMAND, ...)
      Preliminary: | MT-Safe | AS-Safe | AC-Safe |  POSIX Safety
      Concepts.
 
      The 'fcntl' function performs the operation specified by COMMAND on
      the file descriptor FILEDES.  Some commands require additional
      arguments to be supplied.  These additional arguments and the
      return value and error conditions are given in the detailed
      descriptions of the individual commands.
 
      Briefly, here is a list of what the various commands are.
 
      'F_DUPFD'
           Duplicate the file descriptor (return another file descriptor
           pointing to the same open file).   Duplicating
           Descriptors.
 
      'F_GETFD'
           Get flags associated with the file descriptor.  
           Descriptor Flags.
 
      'F_SETFD'
           Set flags associated with the file descriptor.  
           Descriptor Flags.
 
      'F_GETFL'
           Get flags associated with the open file.   File Status
           Flags.
 
      'F_SETFL'
           Set flags associated with the open file.   File Status
           Flags.
 
      'F_GETLK'
           Test a file lock.   File Locks.
 
      'F_SETLK'
           Set or clear a file lock.   File Locks.
 
      'F_SETLKW'
           Like 'F_SETLK', but wait for completion.   File Locks.
 
      'F_GETOWN'
           Get process or process group ID to receive 'SIGIO' signals.
            Interrupt Input.
 
      'F_SETOWN'
           Set process or process group ID to receive 'SIGIO' signals.
            Interrupt Input.
 
      This function is a cancellation point in multi-threaded programs.
      This is a problem if the thread allocates some resources (like
      memory, file descriptors, semaphores or whatever) at the time
      'fcntl' is called.  If the thread gets canceled these resources
      stay allocated until the program ends.  To avoid this calls to
      'fcntl' should be protected using cancellation handlers.
 
Info Catalog (libc.info.gz) Asynchronous I/O (libc.info.gz) Low-Level I/O (libc.info.gz) Duplicating Descriptors
automatically generated by info2html