#include <signal.h> int sigwaitinfo( const sigset_t *set, siginfo_t *info);
The sigwaitinfo() function selects a pending signal from set, clears it from the set of pending signals for the thread or process, and returns that signal number in the si_signo member in the structure that is referenced by info. If prior to the call to sigwaitinfo() there are multiple pending instances of a single signal number, upon successful return the number of remaining signals for that signal number is decremented by one.
If no signal in set is pending at the time of the call, the thread shall be suspended. The thread does not resume until one or more signals in set become pending.
The signals defined by set are required to be blocked at the time of the call to sigwaitinfo(); otherwise, sigwaitinfo() is not successful, and an [EINVAL] error is returned. The signals SIGKILL or SIGStop cannot be selected. Any attempt to use sigwaitinfo() to select these signals is simply ignored, and no error is returned.
The signal action for the signal in set that is returned in the member si_signo in the structure referenced by info is not taken.
If more than one thread is using a sigwait function to wait for the same signal, only one of these threads will return from the sigwait function with the signal number. If more than one thread is waiting for the same signal, the first thread to wait on the signal will return from the sigwait function.
None.
0 | sigwaitinfo() was successful. |
-1 | sigwaitinfo() was not successful. The errno variable is set to indicate the reason. |
If sigwaitinfo() is not successful, errno usually indicates the following error. Under some conditions, errno could indicate an error other than that listed here.
The value specified for the argument is not correct.
A function was passed incorrect argument values, or an operation was attempted on an object and the operation specified is not supported for that type of object.
An argument value is not valid, out of range, or NULL.
One of the following has occurred:
Process not enabled for signals.
An attempt was made to call a signal function under one of the following conditions:
The sigwaitinfo() function enables a process for signals if the process is not already enabled for signals. For details, see Qp0sEnableSignals()--Enable Process for Signals. If the system has not been enabled for signals, sigwaitinfo() is not successful, and an [ENOTSIGINIT] error is returned.
See Code disclaimer information for information pertaining to code examples.
The following example suspends processing by using the sigwaitinfo() function and determines the current time:
Note: The signal catching function is not called.
#include <signal.h> #include <unistd.h> #include <stdio.h> #include <time.h> extern int errno; void catcher( int sig ) { printf( "Signal catcher called for signal %d\n", sig ); } void timestamp( char *str ) { time_t t; time( T ); printf( "The time %s is %s\n", str, ctime(T) ); } int main( int argc, char *argv[] ) { int result = 0; struct sigaction sigact; sigset_t waitset; siginfo_t info; sigemptyset( &sigact.sa_mask ); sigact.sa_flags = 0; sigact.sa_handler = catcher; sigaction( SIGALRM, &sigact, NULL ); sigemptyset( &waitset ); sigaddset( &waitset, SIGALRM ); sigprocmask( SIG_BLOCK, &waitset, NULL ); alarm( 10 ); timestamp( "before sigwaitinfo(" ); result = sigwaitinfo( &waitset, &info ); if( result == 0 ) printf( "sigwaitinfo() returned for signal %d\n", info.si_signo ); else { printf( "sigwait() returned error number %d\n", errno ); perror( "sigwait() function failed\n" ); } timestamp( "after sigwaitinfo()" ); return( result ); }
The time before sigwaitinfo() is Tue Jul 15 11:22:56 1997 sigwaitinfo() returned for signal 14 The time after sigwaitinfo() is Tue Jul 15 11:23:07 1997
Top | UNIX-Type APIs | APIs by category |