[Previous]
[Contents]
[Next]

sigsuspend()

replace the signal mask, and then suspend the process

Synopsis:

#include <signal.h>
int sigsuspend( const sigset_t *sigmask );

Description:

The sigsuspend() function replaces the process's signal mask with the set of signals pointed to by sigmask and then suspends the process until delivery of a signal whose action is either to execute a signal-catching function (then return), or to terminate the process.

Returns:

A value of -1 is returned (if it returns at all), and errno is set.

Errors:

EINTR
A signal is caught by the calling process, and control is returned from the signal-catching function.

Examples:

/*
 * This program pauses until a signal other than
 * a SIGINT occurs. In this case a SIGALRM.
 */
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>

sigset_t    set;

void main()
  {
    sigemptyset( &set );
    sigaddset( &set, SIGINT );

    printf( "Program suspended and immune to breaks.\n" );
    printf( "A SIGALRM will terminate the program"
        " in 10 seconds.\n" );
    alarm( 10 );
    sigsuspend( &set );
  }

Classification:

POSIX 1003.1

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, pause(), sigaction(), sigpending(), sigprocmask()


[Previous]
[Contents]
[Next]