Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/sigprocmask.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/sigprocmask.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/sigprocmask.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/sigprocmask.html on line 8

sigprocmask()

Examine or change the signal mask for a thread

Synopsis:

#include <signal.h>

int sigprocmask( int how,
                 const sigset_t *set,
                 sigset_t *oset );

Arguments:

how
The manner in which you want to change the set:
set
NULL, or a pointer to a sigset_t object that defines the signals that you want to change in the thread's signal mask. If this argument is NULL, the how argument is ignored.
oset
NULL, or a pointer to a sigset_t object that the function sets to indicate the thread's current signal mask.

Library:

libc

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

Description:

The sigprocmask() function is used to examine or change (or both) the signal mask for the calling thread. If the value of set isn't NULL, it points to a set of signals to be used to change the currently blocked set.

The set argument isn't changed. The resulting set is maintained in the process table of the calling thread. If a signal occurs on a signal that's masked, it becomes pending, but doesn't affect the execution of the process. You can examine pending signals by calling sigpending(). When a pending signal is unmasked, it's acted upon immediately, before this function returns.

When a signal handler is invoked, the signal responsible is automatically masked before its handler is called. If the handler returns normally, the operating system restores the signal mask present just before the handler was called as an atomic operation. Changes made using sigprocmask() in the handler are undone.

The sigaction() function lets you specify any mask that's applied before a handler is invoked. This can simplify multiple signal handler design.


Note: To maintain code portability, use pthread_sigmask() in a multithreaded application.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EAGAIN
Insufficient system resources are available to mask the signals.
EFAULT
A fault occurred trying to access the buffers provided.
EINVAL
The value of how is invalid, or you tried to set SIGKILL or SIGSTOP to something other than SIG_DFL.

Examples:

#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>

int main( void )
  {
    sigset_t set, oset, pset;

    sigemptyset( &set );
    sigaddset( &set, SIGINT );
    sigprocmask( SIG_BLOCK, &set, &oset );
    printf( "Old set was %8.8ld.\n", oset );

    sigpending( &pset );
    printf( "Pending set is %8.8ld.\n", pset );

    kill( getpid(), SIGINT );

    sigpending( &pset );
    printf( "Pending set is %8.8ld.\n", pset );

    sigprocmask( SIG_UNBLOCK, &set, &oset );

    /* The program terminates with a SIGINT */
    return( EXIT_SUCCESS );
  }

Classification:

POSIX 1003.1 CX

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

See also:

kill(), pthread_sigmask(), raise(), sigaction(), sigaddset(), sigdelset(), sigemptyset(), sigfillset(), sigismember(), signal(), SignalProcmask(), sigpending()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/s/sigprocmask.html on line 254

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/s/sigprocmask.html on line 254