ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzab6_5.4.0.1/csignals.htm

143 lines
9.1 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="concept" />
<meta name="DC.Title" content="Signals" />
<meta name="abstract" content="An application program can request to be notified asynchronously (request that the system send a signal) when a condition that the application is interested in occurs." />
<meta name="description" content="An application program can request to be notified asynchronously (request that the system send a signal) when a condition that the application is interested in occurs." />
<meta name="DC.Relation" scheme="URI" content="aconcepts.htm" />
<meta name="DC.Relation" scheme="URI" content="coobd.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/accept.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/sendms.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/sendto.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/write.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/writev.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/read.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/readv.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/connec.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/recvfr.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/recvms.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/recv.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/send.htm" />
<meta name="DC.Relation" scheme="URI" content="../apis/sselect.htm" />
<meta name="DC.Relation" scheme="URI" content="xsignals.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2001, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2001, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="csignals" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Signals</title>
</head>
<body id="csignals"><a name="csignals"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Signals</h1>
<div><p>An application program can request to be notified asynchronously
(request that the system send a <dfn class="term">signal</dfn>) when a condition that
the application is interested in occurs.</p>
<p>There are two asynchronous signals that sockets send to an application. </p>
<ol><li><dfn class="term">SIGUR</dfn>G is a signal that is sent when out-of-band (OOB) data
is received on a socket for which the concept of OOB data is supported. For
example, a socket with an address family of AF_INET and a type of SOCK_STREAM
can be conditioned to send a SIGURG signal.</li>
<li><dfn class="term">SIGIO</dfn> is a signal that is sent when normal data, OOB data,
error conditions, or just about anything happens on any type of socket.</li>
</ol>
<p>The application should ensure that it is able to handle receiving a signal
before it requests the system to send signals. This is done by setting up <dfn class="term">signal
handlers</dfn>. One way to set a signal handler is by issuing the <span class="apiname">sigaction()</span> call.</p>
<p>An application requests the system to send the <dfn class="term">SIGURG</dfn> signal
by one of the following methods: </p>
<ul><li>Issuing a <span class="apiname">fcntl()</span> call and specifying a process ID
or a process group ID with the F_SETOWN command.</li>
<li>Issuing an <span class="apiname">ioctl()</span> call and specifying the FIOSETOWN
or the SIOCSPGRP command (request).</li>
</ul>
<p>An application requests the system to send the <dfn class="term">SIGIO</dfn> signal
in two steps. First it must set the process ID or the process group ID as
previously described for the <dfn class="term">SIGURG</dfn> signal. This is to inform
the system of where the application wants the signal to be delivered. Second,
the application must do either of the following tasks: </p>
<ul><li>Issue the <span class="apiname">fcntl()</span> call and specify the F_SETFL command
with the FASYNC flag.</li>
<li>Issue the <span class="apiname">ioctl()</span> call and specify the FIOASYNC command.</li>
</ul>
<p>This step requests the system to generate the SIGIO signal. Note that these
steps can be done in any order. Also note that if an application issues these
requests on a listening socket, the values set by the requests are inherited
by all sockets that are returned to the application from the <span class="apiname">accept()</span> function.
That is, newly accepted sockets also have the same process ID or process group
ID as well as the same information with regard to sending the SIGIO signal.</p>
<p>A socket can also generate synchronous signals on error conditions. Whenever
an application receives [EPIPE] an <em>errno</em> on a socket function, a SIGPIPE
signal is delivered to the process that issued the operation receiving the <em>errno</em> value.
On a Berkeley Socket Distribution (BSD) implementation, by default the SIGPIPE
signal ends the process that received the <em>errno</em> value. To remain compatible
with previous releases of the i5/OS™ implementation, the i5/OS implementation
uses a default behavior of ignoring for the SIGPIPE signal. This
ensures that existing applications are not negatively affected by the addition
of the signals function.</p>
<div class="p">When a signal is delivered to a process that is blocked on a sockets function,
the function returns from the wait with the <em>[EINTR] errno</em> value, allowing
the application's signal handler to run. The functions for which this occur
are: <ul><li><span class="apiname">accept()</span></li>
<li><span class="apiname">connect()</span></li>
<li><img src="./delta.gif" alt="Start of change" /><span class="apiname">poll()</span><img src="./deltaend.gif" alt="End of change" /></li>
<li><span class="apiname">read()</span></li>
<li><span class="apiname">readv()</span></li>
<li><span class="apiname">recv()</span></li>
<li><span class="apiname">recvfrom()</span></li>
<li><span class="apiname">recvmsg()</span></li>
<li><span class="apiname">select()</span></li>
<li><span class="apiname">send()</span></li>
<li><span class="apiname">sendto()</span></li>
<li><span class="apiname">sendmsg()</span></li>
<li><span class="apiname">write()</span></li>
<li><span class="apiname">writev()</span></li>
</ul>
</div>
<p>It is important to note that signals do not provide the
application program with a socket descriptor that identifies where the condition
being signalled actually exists. Thus, if the application program is using
multiple socket descriptors, it must either poll the descriptors or use the <span class="apiname">select()</span> call
to determine why the signal was received.</p>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="aconcepts.htm" title="Advanced socket concepts go beyond a general discussion of what sockets are and how they work. They provide ways to design socket applications for larger and more complex networks.">Advanced socket concepts</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="coobd.htm" title="Out-of-band (OOB) data is user-specific data that only has meaning for connection-oriented (stream) sockets.">Out-of-band data</a></div>
</div>
<div class="relref"><strong>Related reference</strong><br />
<div><a href="xsignals.htm" title="Signals allow you to be notified when a process or application becomes blocked.">Example: Use signals with blocking socket APIs</a></div>
</div>
<div class="relinfo"><strong>Related information</strong><br />
<div><a href="../apis/accept.htm">accept()</a></div>
<div><a href="../apis/sendms.htm">sendmsg()</a></div>
<div><a href="../apis/sendto.htm">sendto()</a></div>
<div><a href="../apis/write.htm">write()</a></div>
<div><a href="../apis/writev.htm">writev()</a></div>
<div><a href="../apis/read.htm">read()</a></div>
<div><a href="../apis/readv.htm">readv()</a></div>
<div><a href="../apis/connec.htm">connect()</a></div>
<div><a href="../apis/recvfr.htm">recvfrom()</a></div>
<div><a href="../apis/recvms.htm">recvmsg()</a></div>
<div><a href="../apis/recv.htm">recv()</a></div>
<div><a href="../apis/send.htm">send()</a></div>
<div><a href="../apis/sselect.htm">select()</a></div>
</div>
</div>
</body>
</html>