#include <unistd.h> int pause( void );
The pause() 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 signal mask. See sigprocmask()--Examine and Change Blocked Signals for details.
If an incoming unblocked signal has an action of end the request or terminate the process, pause() never returns to the caller. If an incoming signal is handled by a signal-catching function, pause() returns after the signal-catching function returns.
None.
None.
There is no return value to indicate successful completion.
If pause() returns, errno indicates the following:
pause() was not successful. The errno variable is set to indicate the reason.
Interrupted function call.
A signal was received and handled by a signal-catching function that returned.
Process not enabled for signals.
An attempt was made to call a signal function under one of the following conditions:
The pause() function enables a process for signals if the process is not already enabled for signals. For details, see Qp0sEnableSignals()--Enable Process for Signals. If the system has not been enabled for signals, pause() is not successful, and an [ENOTSIGINIT] error is returned.
See Code disclaimer information for information pertaining to code examples.
The following example suspends processing using the pause() function and determines the current time:
#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 ); }
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
Top | UNIX-Type APIs | APIs by category |