[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    sigwait(2) manual page Table of Contents

Name

sigwait - wait until a signal is posted

Synopsis

#include <signal.h>

int sigwait(sigset_t *set);

Posix

cc [ flag... ] file ... -D_POSIX_PTHREAD_SEMANTICS [ library... ]

#include <signal.h>

int sigwait(const sigset_t *set, int *sig);

Description

sigwait() selects a signal in set that is pending on the calling thread (see thr_create(3T) ) or LWP . If no signal in set is pending, then sigwait() blocks until a signal in set becomes pending. The selected signal is cleared from the set of signals pending on the calling thread or LWP and the number of the signal is returned, or in the POSIX version placed in sig. The selection of a signal in set is independent of the signal mask of the calling thread or LWP . This means a thread or LWP can synchronously wait for signals that are being blocked by the signal mask of the calling thread or LWP . To ensure that only the caller receives the signals defined in set, all threads should have signals in set masked including the calling thread.

If sigwait() is called on an ignored signal, then the occurrence of the signal will be ignored, unless sigaction() changes the disposition. If more than one thread or LWP waits for the same signal, only one is unblocked when the signal arrives.

Return Values

Upon successful completion, sigwait() returns a signal number. Otherwise, it returns a value of -1 and sets errno to indicate an error. Upon successful completion, the POSIX version of sigwait() returns zero and stores the received signal number at the location pointed to by sig. Otherwise, it returns the error number.

Errors

If any of the following conditions are detected, sigwait() fails. The Solaris version returns -1 and sets errno, whereas the POSIX version returns one of the following errors:

EINVAL
set contains an unsupported signal number.
EFAULT
set points to an invalid address.

See Also

sigaction(2) , sigpending(2) , sigprocmask(2) , sigsuspend(2) , thr_create(3T) , thr_sigsetmask(3T) , signal(5)

Notes

sigwait() cannot be used to wait for signals that cannot be caught (see sigaction(2) ). This restriction is silently imposed by the system.

In Solaris 2.4 and earlier releases, the call to sigwait() from a multi-threaded process overrode the signal’s ignore disposition; even if a signal’s disposition was SIG_IGN a call to sigwait() resulted in catching the signal, if generated. This is unspecified behavior from the standpoint of the POSIX 1003.1c spec.

In Solaris 2.5, the behavior of sigwait() was corrected, so that it does not override the signal’s ignore disposition. This change can cause applications that rely on the old behavior to break. Applications should employ sigwait() as follows: Install a dummy signal handler, thereby changing the disposition from SIG_IGN to having a handler. Then, any calls to sigwait() for this signal would catch it upon generation.

Solaris 2.4 and earlier releases provided a sigwait() facility as specified in POSIX.1c Draft 6. The final POSIX.1c standard changed the interface as described above. Support for the Draft 6 interface is provided for compatibility only and may not be supported in future releases. New applications and libraries should use the POSIX standard interface.


Table of Contents