blob: 748a265bb8a88e0bd3d0c77fccf2e19c8ca32507 [file] [log] [blame]
<html lang="en">
<head>
<title>Interrupt Input - The GNU C Library</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="The GNU C Library">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Low_002dLevel-I_002fO.html#Low_002dLevel-I_002fO" title="Low-Level I/O">
<link rel="prev" href="File-Locks.html#File-Locks" title="File Locks">
<link rel="next" href="IOCTLs.html#IOCTLs" title="IOCTLs">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<!--
This file documents the GNU C library.
This is Edition 0.12, last updated 2007-10-27,
of `The GNU C Library Reference Manual', for version
2.8 (Sourcery G++ Lite 2011.03-41).
Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002,
2003, 2007, 2008, 2010 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Free Software Needs Free Documentation''
and ``GNU Lesser General Public License'', the Front-Cover texts being
``A GNU Manual'', and with the Back-Cover Texts as in (a) below. A
copy of the license is included in the section entitled "GNU Free
Documentation License".
(a) The FSF's Back-Cover Text is: ``You have the freedom to
copy and modify this GNU manual. Buying copies from the FSF
supports it in developing GNU and promoting software freedom.''-->
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
<link rel="stylesheet" type="text/css" href="../cs.css">
</head>
<body>
<div class="node">
<a name="Interrupt-Input"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="IOCTLs.html#IOCTLs">IOCTLs</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="File-Locks.html#File-Locks">File Locks</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Low_002dLevel-I_002fO.html#Low_002dLevel-I_002fO">Low-Level I/O</a>
<hr>
</div>
<h3 class="section">13.16 Interrupt-Driven Input</h3>
<p><a name="index-interrupt_002ddriven-input-1378"></a>If you set the <code>O_ASYNC</code> status flag on a file descriptor
(see <a href="File-Status-Flags.html#File-Status-Flags">File Status Flags</a>), a <code>SIGIO</code> 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
<code>F_SETOWN</code> command to the <code>fcntl</code> function. If the file
descriptor is a socket, this also selects the recipient of <code>SIGURG</code>
signals that are delivered when out-of-band data arrives on that socket;
see <a href="Out_002dof_002dBand-Data.html#Out_002dof_002dBand-Data">Out-of-Band Data</a>. (<code>SIGURG</code> is sent in any situation
where <code>select</code> would report the socket as having an &ldquo;exceptional
condition&rdquo;. See <a href="Waiting-for-I_002fO.html#Waiting-for-I_002fO">Waiting for I/O</a>.)
<p>If the file descriptor corresponds to a terminal device, then <code>SIGIO</code>
signals are sent to the foreground process group of the terminal.
See <a href="Job-Control.html#Job-Control">Job Control</a>.
<p><a name="index-fcntl_002eh-1379"></a>The symbols in this section are defined in the header file
<samp><span class="file">fcntl.h</span></samp>.
<!-- fcntl.h -->
<!-- BSD -->
<div class="defun">
&mdash; Macro: int <b>F_GETOWN</b><var><a name="index-F_005fGETOWN-1380"></a></var><br>
<blockquote><p>This macro is used as the <var>command</var> argument to <code>fcntl</code>, to
specify that it should get information about the process or process
group to which <code>SIGIO</code> signals are sent. (For a terminal, this is
actually the foreground process group ID, which you can get using
<code>tcgetpgrp</code>; see <a href="Terminal-Access-Functions.html#Terminal-Access-Functions">Terminal Access Functions</a>.)
<p>The return value is interpreted as a process ID; if negative, its
absolute value is the process group ID.
<p>The following <code>errno</code> error condition is defined for this command:
<dl>
<dt><code>EBADF</code><dd>The <var>filedes</var> argument is invalid.
</dl>
</p></blockquote></div>
<!-- fcntl.h -->
<!-- BSD -->
<div class="defun">
&mdash; Macro: int <b>F_SETOWN</b><var><a name="index-F_005fSETOWN-1381"></a></var><br>
<blockquote><p>This macro is used as the <var>command</var> argument to <code>fcntl</code>, to
specify that it should set the process or process group to which
<code>SIGIO</code> signals are sent. This command requires a third argument
of type <code>pid_t</code> to be passed to <code>fcntl</code>, so that the form of
the call is:
<pre class="smallexample"> fcntl (<var>filedes</var>, F_SETOWN, <var>pid</var>)
</pre>
<p>The <var>pid</var> argument should be a process ID. You can also pass a
negative number whose absolute value is a process group ID.
<p>The return value from <code>fcntl</code> with this command is -1
in case of error and some other value if successful. The following
<code>errno</code> error conditions are defined for this command:
<dl>
<dt><code>EBADF</code><dd>The <var>filedes</var> argument is invalid.
<br><dt><code>ESRCH</code><dd>There is no process or process group corresponding to <var>pid</var>.
</dl>
</p></blockquote></div>
<!-- ??? This section could use an example program. -->
</body></html>