249 lines
6.3 KiB
HTML
249 lines
6.3 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
|
<title>sigpending()--Examine Pending Signals</title>
|
|
<!-- 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. -->
|
|
<!-- Begin Header Records ========================================== -->
|
|
<!-- UNIX5 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!-- Edited by Kersten Feb 02 -->
|
|
<!-- This file has undergone html cleanup June 2002 by JET -->
|
|
<!--End Header Records -->
|
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</head>
|
|
<body>
|
|
<a name="Top_Of_Page"></a>
|
|
|
|
<!-- Java sync-link -->
|
|
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
|
|
</script>
|
|
|
|
<h2>sigpending()--Examine Pending Signals</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
Syntax<br>
|
|
<pre>
|
|
#include <signal.h>
|
|
|
|
int sigpending( sigset_t <em>*set</em> );
|
|
</pre>
|
|
|
|
<br>
|
|
Service Program Name: QPOSSRV1<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Yes<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <strong>sigpending()</strong> function returns signals that are blocked
|
|
from delivery and pending for either the calling thread or the process. This
|
|
information is represented as a signal set stored in <em>set</em>. For more
|
|
information on examining the signal set pointed to by <em>set</em>, see <a
|
|
href="sigismbr.htm">sigismember()--Test for Signal in Signal Set</a>.</p>
|
|
|
|
<br>
|
|
<!-- Please NOTE: DO NOT DELETE THIS SECTION if this API has no authorities and locks. -->
|
|
<!-- Instead, use the commented out coding below to indicate NONE. -->
|
|
<h3>Authorities and Locks</h3>
|
|
|
|
<!-- Use this if there are no authorities and locks. -->
|
|
<p>None.</p>
|
|
|
|
<br>
|
|
<h3>Parameters</h3>
|
|
|
|
<dl>
|
|
<dt><strong><em>*set</em></strong></dt>
|
|
|
|
<dd>(Output) A pointer to the space where the signal set information is
|
|
stored.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="5 95" -->
|
|
<tr>
|
|
<td align="left" valign="top"><em>0</em></td>
|
|
<td align="left" valign="top"><strong>sigpending()</strong> was
|
|
successful.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top"><em>-1</em></td>
|
|
<td align="left" valign="top"><strong>sigpending()</strong> was not successful.
|
|
The <em>errno</em> variable is set to indicate the error.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<br>
|
|
<h3>Error Conditions</h3>
|
|
|
|
<p>If <strong>sigpending()</strong> is not successful, <em>errno</em> usually
|
|
indicates the following error. Under some conditions, <em>errno</em> could
|
|
indicate an error other than that listed here.</p>
|
|
|
|
<dl>
|
|
<dt><em>[ENOTSIGINIT]</em></dt>
|
|
|
|
<dd>
|
|
<p>Process not enabled for signals.</p>
|
|
|
|
<p>An attempt was made to call a signal function under one of the following
|
|
conditions:</p>
|
|
|
|
<ul>
|
|
<li>The signal function is being called for a process that is not enabled for
|
|
asynchronous signals.<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>The signal function is being called when the system signal controls have
|
|
not been initialized.</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li>The <<strong>signal.h</strong>> file (see <a href="unix13.htm">Header
|
|
Files for UNIX-Type Functions</a>)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigaset.htm">sigaddset()</a>--Add Signal to Signal Set<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigdset.htm">sigdelset()</a>--Delete Signal from Signal Set<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigeset.htm">sigemptyset()</a>--Initialize and Empty Signal
|
|
Set<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigfset.htm">sigfillset()</a>--Initialize and Fill Signal Set<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigismbr.htm">sigismember()</a>--Test for Signal in Signal Set<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigpmsk.htm">sigprocmask()</a>--Examine and Change Blocked
|
|
Signals</li>
|
|
</ul>
|
|
|
|
<br>
|
|
<h3>Example</h3>
|
|
|
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
|
for information pertaining to code examples.</p>
|
|
|
|
<p>The following example returns blocked and pending signals:</p>
|
|
|
|
<pre>
|
|
#include <signal.h>
|
|
#include <unistd.h>
|
|
#include <stdio.h>
|
|
|
|
void catcher( int sig ) {
|
|
puts( "inside catcher() function\n" );
|
|
}
|
|
|
|
void check_pending( int sig, char *signame ) {
|
|
|
|
sigset_t sigset;
|
|
|
|
if( sigpending( &sigset ) != 0 )
|
|
perror( "sigpending() error\n" );
|
|
|
|
else if( sigismember( &sigset, sig ) )
|
|
printf( "a %s signal is pending\n", signame );
|
|
else
|
|
printf( "no %s signals are pending\n", signame );
|
|
}
|
|
|
|
int main( int argc, char *argv[] ) {
|
|
|
|
struct sigaction sigact;
|
|
sigset_t sigset;
|
|
|
|
sigemptyset( &sigact.sa_mask );
|
|
sigact.sa_flags = 0;
|
|
sigact.sa_handler = catcher;
|
|
|
|
if( sigaction( SIGUSR1, &sigact, NULL ) != 0 )
|
|
perror( "sigaction() error\n" );
|
|
|
|
else {
|
|
sigemptyset( &sigset );
|
|
sigaddset( &sigset, SIGUSR1 );
|
|
if ( sigprocmask( SIG_SETMASK, &sigset, NULL ) != 0)
|
|
perror( "sigprocmask() error\n" );
|
|
|
|
else {
|
|
printf( "SIGUSR1 signals are now blocked\n" );
|
|
|
|
kill( getpid(), SIGUSR1 );
|
|
printf( "after kill()\n" );
|
|
|
|
check_pending( SIGUSR1, "SIGUSR1" );
|
|
|
|
sigemptyset( &sigset );
|
|
sigprocmask( SIG_SETMASK, &sigset, NULL );
|
|
printf( "SIGUSR1 signals are no longer blocked\n" );
|
|
|
|
check_pending( SIGUSR1, "SIGUSR1" );
|
|
}
|
|
}
|
|
return( 0 );
|
|
}
|
|
</pre>
|
|
|
|
<br>
|
|
<h3>Output:</h3>
|
|
|
|
<pre>
|
|
SIGUSR1 signals are now blocked
|
|
after kill()
|
|
a SIGUSR1 signal is pending
|
|
inside catcher() function
|
|
SIGUSR1 signals are no longer blocked
|
|
no SIGUSR1 signals are pending
|
|
</pre>
|
|
|
|
<br>
|
|
<hr>
|
|
API introduced: V3R6
|
|
|
|
<hr>
|
|
<center>
|
|
<table cellpadding="2" cellspacing="2">
|
|
<tr align="center">
|
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
|
|
</tr>
|
|
</table>
|
|
</center>
|
|
</body>
|
|
</html>
|
|
|