fcntl

Controls file handles

Local Servers:nonblocking
Remote Servers:nonblocking
Classification:POSIX
Platform:NLM
Service:Operating System I/O

Syntax

  #include <fcntl.h>  
   
  int fcntl  (  
     int   handle,   
     int   cmd,  
     int   arg);
  

Parameters

handle
(IN) Specifies a file handle to be operated on by cmd.
cmd
(IN) Specifies one of two commands to act on the specified file handle.
arg
(IN/OUT) Specifies the handle status flags.

Return Values

Upon successful completion of the F_GETFL command, fcntl returns the current value of the requested flag. Otherwise, a value of -1 is returned and errno indicates the error.

Decimal

Constant

Description

4

EBADF

The specified file handle is not a valid one.

9

EINVAL

Either cmd or val is not supported.

35

EWOULDBLOCK

Either no data is available to a read call or a write operation is in a blocking mode.

Remarks

The fcntl function provides for file control over file handles. The handle parameter is a file handle to be operated on by cmd. The cmd parameter includes either the F_GETFL or the F_SETFL commands described below:

F_GETFL

Get handle status flags.

F_SETFL

Set handle status flags.

Flags are passed in the arg parameter. The FNDELAY flag is defined for the F_GETFL and F_SETFL commands. It establishes a nonblocking I/O mode; if no data is available to a read call or if a write operation is in a blocking mode, the call returns a value of -1 with the error EWOULDBLOCK.

See Also

ioctl