suspend the process until delivery of a signal
#include <unistd.h> int pause( void );
The pause() function suspends the calling process until delivery of a signal whose action is either to execute a signal handler or to terminate the process.
If the action is to terminate the process, pause() does not return. If the action is to execute a signal handler, pause() returns after the signal handler returns.
Upon error, pause() returns -1 and sets errno to EINTR, otherwise this function never returns.
#include <stdio.h> #include <unistd.h> void main() { /* set an alarm to go off in 5 seconds */ alarm( 5 ); /* * Wait until we receive a SIGALRM signal. However, * since we do not have a signal handler, any signal * will kill us. */ printf( "Hang around, " " waiting to die in 5 seconds\n" ); pause(); }
POSIX 1003.1
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |