sigsuspend()

Replace the signal mask, and then suspend the thread

Synopsis:

#include <signal.h>

int sigsuspend( const sigset_t *sigmask );

Arguments:

sigmask
A pointer to a sigset_t object that specifies the signals that you want in the thread's signal mask.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

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

Returns:

-1 (if the function returns); errno is set.

Errors:

EFAULT
A fault occurred trying to access the buffers provided.
EINTR
A signal was caught by the calling thread, 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;

int main( void )
  {
    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 );
    return( EXIT_SUCCESS );
  }

Classification:

POSIX 1003.1

Safety:  
Cancellation point Yes
Interrupt handler No
Signal handler Yes
Thread Yes

Last modified: 2013-12-23

comments powered by Disqus