The GNU C Library: Interrupt Input

Next: , Previous: , Up: Low-Level I/O   [Contents][Index]


13.18 Interrupt-Driven Input

If you set the O_ASYNC status flag on a file descriptor (see 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 Out-of-Band Data. (SIGURG is sent in any situation where select would report the socket as having an “exceptional condition”. See Waiting for I/O.)

If the file descriptor corresponds to a terminal device, then SIGIO signals are sent to the foreground process group of the terminal. See 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 Terminal Access Functions.)

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.


Next: , Previous: , Up: Low-Level I/O   [Contents][Index]