254 lines
6.4 KiB
HTML
254 lines
6.4 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>pause()--Suspend Process Until Signal Received</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 -->
|
|
<!--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>pause()--Suspend Process Until Signal Received</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
Syntax<br>
|
|
<pre>
|
|
#include <unistd.h>
|
|
|
|
int pause( void );
|
|
</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>pause()</strong> function suspends processing of the calling
|
|
thread. The thread does not resume until a signal is delivered whose action is
|
|
to call a signal-catching function, end the request, or terminate the process.
|
|
Some signals can be blocked by the thread's <em>signal mask</em>. See <a href=
|
|
"sigpmsk.htm">sigprocmask()--Examine and Change Blocked Signals</a> for
|
|
details.</p>
|
|
|
|
<p>If an incoming unblocked signal has an action of end the request or
|
|
terminate the process, <strong>pause()</strong> never returns to the caller. If
|
|
an incoming signal is handled by a signal-catching function,
|
|
<strong>pause()</strong> returns after the signal-catching function
|
|
returns.</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>
|
|
|
|
<p>None.</p>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<p>There is no return value to indicate successful completion.</p>
|
|
|
|
<br>
|
|
<h3>Error Conditions</h3>
|
|
|
|
<p>If <strong>pause()</strong> returns, <em>errno</em> indicates the
|
|
following:</p>
|
|
|
|
<dl>
|
|
<dt><em>-1</em></dt>
|
|
|
|
<dd><p><strong>pause()</strong> was not successful. The <em>errno</em> variable is
|
|
set to indicate the reason.</p> </dd>
|
|
|
|
<dt><em>[EINTR]</em></dt>
|
|
|
|
<dd><p>Interrupted function call.</p>
|
|
<p>A signal was received and handled by a signal-catching function that
|
|
returned. </p>
|
|
</dd>
|
|
|
|
<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.</li>
|
|
|
|
<li>The signal function is being called when the system signal controls have
|
|
not been initialized.<br>
|
|
</li>
|
|
|
|
</ul>
|
|
<br></dd>
|
|
|
|
<dt><em>[EWOULDBLOCK]</em></dt>
|
|
|
|
<dd>Operation would have caused the process to be suspended.
|
|
The current thread state would prevent the signal function from completing.
|
|
</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Usage Notes</h3>
|
|
|
|
<p>The <strong>pause()</strong> function enables a process for signals if the
|
|
process is not already enabled for signals. For details, see <a href=
|
|
"sigesig.htm">Qp0sEnableSignals()--Enable Process for Signals</a>. If the
|
|
system has not been enabled for signals, <strong>pause()</strong> is not
|
|
successful, and an [ENOTSIGINIT] error is returned.</p>
|
|
|
|
<br>
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li>The <<strong>unistd.h</strong>> file (see <a href="unix13.htm">Header
|
|
Files for UNIX-Type Functions</a>)<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigalarm.htm">alarm()</a>--Set Schedule for Alarm Signal<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigkill.htm">kill()</a>--Send Signal to Process or Group of
|
|
Processes<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigdsig.htm">Qp0sDisableSignals()</a>--Disable Process for
|
|
Signals<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigesig.htm">Qp0sEnableSignals()</a>--Enable Process for
|
|
Signals<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigpmsk.htm">sigprocmask()</a>--Examine and Change Blocked
|
|
Signals<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigsusp.htm">sigsuspend()</a>--Wait for Signal<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigtwait.htm">sigtimedwait()</a>--Synchronously Accept a Signal for
|
|
Interval of Time<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigwait.htm">sigwait()</a>--Synchronously Accept a Signal<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigwaiti.htm">sigwaitinfo()</a>--Synchronously Accept a Signal and
|
|
Signal Data<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li><a href="sigsleep.htm">sleep()</a>--Suspend Processing for Interval of
|
|
Time</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 suspends processing using the <strong>pause()</strong>
|
|
function and determines the current time:</p>
|
|
|
|
<pre>
|
|
#include <unistd.h>
|
|
#include <signal.h>
|
|
#include <stdio.h>
|
|
#include <time.h>
|
|
|
|
void catcher( int sig ) {
|
|
printf( "Signal catcher called for signal %d\n", sig );
|
|
}
|
|
|
|
void timestamp( char *str ) {
|
|
time_t t;
|
|
|
|
time(&t);
|
|
printf( "The time %s is %s\n", str, ctime(&t) );
|
|
}
|
|
|
|
int main( int argc, char *argv[] ) {
|
|
|
|
struct sigaction sigact;
|
|
|
|
sigemptyset( &sigact.sa_mask );
|
|
sigact.sa_flags = 0;
|
|
sigact.sa_handler = catcher;
|
|
sigaction( SIGALRM, &sigact, NULL );
|
|
|
|
alarm( 10 );
|
|
|
|
timestamp( "before pause" );
|
|
pause();
|
|
timestamp( "after pause" );
|
|
|
|
return( 0 );
|
|
}
|
|
</pre>
|
|
|
|
<br>
|
|
<h3>Output:</h3>
|
|
|
|
<pre>
|
|
The time before pause is Sun Jan 22 11:09:08 1995
|
|
Signal catcher called for signal 14
|
|
The time after pause is Sun Jan 22 11:09:18 1995
|
|
</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>
|
|
|