www.delorie.com/gnu/docs/glibc/libc_265.html   search  
 
Buy the book!


The GNU C Library

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

13.16 Interrupt-Driven Input

If you set the O_ASYNC status flag on a file descriptor (see section 13.14 File Status Flags), a SIGIO signal is sent whenever input or output becomes possible on that file descriptor. The process or process group to receive the signal can be selected by using the F_SETOWN command to the fcntl function. If the file descriptor is a socket, this also selects the recipient of SIGURG signals that are delivered when out-of-band data arrives on that socket; see 16.9.8 Out-of-Band Data. (SIGURG is sent in any situation where select would report the socket as having an "exceptional condition". See section 13.8 Waiting for Input or Output.)

If the file descriptor corresponds to a terminal device, then SIGIO signals are sent to the foreground process group of the terminal. See section 27. Job Control.

The symbols in this section are defined in the header file `fcntl.h'.

Macro: int F_GETOWN
This macro is used as the command argument to fcntl, to specify that it should get information about the process or process group to which SIGIO signals are sent. (For a terminal, this is actually the foreground process group ID, which you can get using tcgetpgrp; see 27.7.3 Functions for Controlling Terminal Access.)

The return value is interpreted as a process ID; if negative, its absolute value is the process group ID.

The following errno error condition is defined for this command:

EBADF
The filedes argument is invalid.

Macro: int F_SETOWN
This macro is used as the command argument to fcntl, to specify that it should set the process or process group to which SIGIO signals are sent. This command requires a third argument of type pid_t to be passed to fcntl, so that the form of the call is:

 
fcntl (filedes, F_SETOWN, pid)

The pid argument should be a process ID. You can also pass a negative number whose absolute value is a process group ID.

The return value from fcntl with this command is -1 in case of error and some other value if successful. The following errno error conditions are defined for this command:

EBADF
The filedes argument is invalid.

ESRCH
There is no process or process group corresponding to pid.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003