[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 2

sigsuspend or sigpause Subroutine

Purpose

Automatically changes the set of blocked signals and waits for a signal.

Library

Standard C Library (libc.a)

Syntax


#include <signal.h>

int sigsuspend ( SignalMask)
const sigset_t *SignalMask;

int sigpause (SignalMask)
int SignalMask;

Description

The sigsuspend subroutine replaces the signal mask of a thread with the set of signals pointed to by the SignalMask parameter. It then suspends execution of the thread until a signal is delivered that executes a signal-catching function or terminates the process. The sigsuspend subroutine does not allow the SIGKILL or SIGSTOP signal to be blocked. If a program attempts to block one of these signals, the sigsuspend subroutine gives no indication of the error.

If delivery of a signal causes the process to end, the sigsuspend subroutine does not return. If delivery of a signal causes a signal-catching function to start, the sigsuspend subroutine returns after the signal-catching function returns, with the signal mask restored to the set that existed prior to the sigsuspend subroutine.

The sigsuspend subroutine sets the signal mask and waits for an unblocked signal as one atomic operation. This means that signals cannot occur between the operations of setting the mask and waiting for a signal. If a program invokes the sigprocmask (SIG_SETMASK) and pause subroutines separately, a signal that occurs between these subroutines might not be noticed by the pause subroutine.

In normal usage, a signal is blocked by using the sigprocmask(SIG_BLOCK,...) subroutine for single-threaded applications, or the sigthreadmask(SIG_BLOCK,...) subroutine for multi-threaded applications (using the libpthreads.a threads library) at the beginning of a critical section. The process/thread then determines whether there is work for it to do. If no work is to be done, the process/thread waits for work by calling the sigsuspend subroutine with the mask previously returned by the sigprocmask or sigthreadmask subroutine.

The sigpause subroutine is provided for compatibility with older UNIX systems; its function is a subset of the sigsuspend subroutine.

Parameter

SignalMask Points to a set of signals.

Return Values

If a signal is caught by the calling thread and control is returned from the signal handler, the calling thread resumes execution after the sigsuspend or sigpause subroutine, which always return a value of -1 and set the errno global variable to EINTR.

Related Information

The pause subroutine, sigprocmask (sigprocmask, sigsetmask, or sigblock Subroutine) subroutine, sigaction or signal (sigaction, sigvec, or signal Subroutine) subroutine, sigthreadmask (sigthreadmask Subroutine) subroutine.

Signal Management in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs provides more information about signal management in multi-threaded processes.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]