Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../usr/man/./man2/sigwait.2
Real path: /usr/share/man/man2/sigwait.2
Zurück
'\" te .\" Copyright (c) 2009, 2020, Oracle and/or its affiliates. .TH sigwait 2 "17 Sep 2020" "Oracle Solaris 11.4" "System Calls" .SH NAME sigwait \- wait until a signal is posted .SH SYNOPSIS .LP .nf #include <signal.h> \fBint\fR \fBsigwait\fR(\fBconst sigset_t *\fR\fIset\fR, \fBint *\fR\fIsig\fR); .fi .LP .nf \fBPOSIX.1c Draft 6\fR cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-D__USE_DRAFT6_PROTOTYPES__\fR [ \fIlibrary\fR...] \fBint\fR \fBsigwait\fR(\fBsigset_t *\fR\fIset\fR); .fi .SH DESCRIPTION .sp .LP The \fBsigwait()\fR function selects a signal in \fIset\fR that is pending on the calling thread. If no signal in \fIset\fR is pending, \fBsigwait()\fR blocks until a signal in \fIset\fR becomes pending. The selected signal is cleared from the set of signals pending on the calling thread and the number of the signal is placed in \fIsig\fR. The selection of a signal in \fIset\fR is independent of the signal mask of the calling thread. This means a thread can synchronously wait for signals that are being blocked by the signal mask of the calling thread. To ensure that only the caller receives the signals defined in \fIset\fR, all threads should have signals in \fIset\fR masked including the calling thread. .sp .LP If more than one thread is using \fBsigwait()\fR to wait for the same signal, no more than one of these threads returns from \fBsigwait()\fR with the signal number. If more than a single thread is blocked in \fBsigwait()\fR for a signal when that signal is generated for the process, it is unspecified which of the waiting threads returns from \fBsigwait()\fR. If the signal is generated for a specific thread, as by \fBpthread_kill\fR(3C), only that thread returns. .sp .LP Should any of the multiple pending signals in the range \fBSIGRTMIN\fR to \fBSIGRTMAX\fR be selected, it will be the lowest numbered one. The selection order between realtime and non-realtime signals, or between multiple pending non-realtime signals, is unspecified. .SH RETURN VALUES .sp .LP Upon successful completion, \fBsigwait()\fR returns 0 and stores the selected signal number at the location pointed to by \fIsig\fR. Otherwise, \fBsigwait()\fR returns an error number to indicate the error; it does not set \fBerrno\fR. .sp .LP The Draft 6 version of \fBsigwait()\fR returns the selected signal number on success. Otherwise, it returns -1 and sets \fBerrno\fR to indicate the error. .SH ERRORS .sp .LP The \fBsigwait()\fR function will fail if: .sp .ne 2 .mk .na \fB\fBEFAULT\fR\fR .ad .RS 10n .rt The \fIset\fR argument points to an invalid address. .RE .sp .ne 2 .mk .na \fB\fBEINTR\fR\fR .ad .RS 10n .rt The wait was interrupted by an unblocked, caught signal. .RE .sp .ne 2 .mk .na \fB\fBEINVAL\fR\fR .ad .RS 10n .rt The \fIset\fR argument contains an unsupported signal number. .RE .SH EXAMPLES .LP \fBExample 1\fR Creating a thread to handle receipt of a signal .sp .LP The following sample C code creates a thread to handle the receipt of a signal. More specifically, it catches the asynchronously generated signal, \fBSIGINT\fR. .sp .in +2 .nf /******************************************************************** * sigint thread handles delivery of signal. Uses sigwait(\|) to wait * for SIGINT signal. ********************************************************************/ #include <pthread.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <synch.h> static void *threadTwo(void *); static void *threadThree(void *); static void *sigint(void *); sigset_t signalSet; int main(void) { pthread_t t; pthread_t t2; pthread_t t3; sigfillset(&signalSet); /* * Block signals in initial thread. New threads will * inherit this signal mask. */ pthread_sigmask(SIG_BLOCK, &signalSet, NULL); printf("Creating threads\en"); pthread_create(&t, NULL, sigint, NULL); pthread_create(&t2, NULL, threadTwo, NULL); pthread_create(&t3, NULL, threadThree, NULL); printf("##################\en"); printf("press CTRL-C to deliver SIGINT to sigint thread\en"); printf("##################\en"); pthread_exit((void *)0); } static void * threadTwo(void *arg) { printf("hello world, from threadTwo [tid: %d]\en", pthread_self()); printf("threadTwo [tid: %d] is now complete and exiting\en", pthread_self()); pthread_exit((void *)0); } static void * threadThree(void *arg) { printf("hello world, from threadThree [tid: %d]\en", pthread_self()); printf("threadThree [tid: %d] is now complete and exiting\en", pthread_self()); pthread_exit((void *)0); } void * sigint(void *arg) { int sig; int err; printf("thread sigint [tid: %d] awaiting SIGINT\en", pthread_self()); err = sigwait(&signalSet, &sig); /* test for SIGINT; could catch other signals */ if (err || sig != SIGINT) abort(); printf("\enSIGINT signal %d caught by sigint thread [tid: %d]\en", sig, pthread_self()); pthread_exit((void *)0); } .fi .in -2 .sp .SH ATTRIBUTES .sp .LP See \fBattributes\fR(7) for descriptions of the following attributes: .sp .TS tab( ) box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Committed _ MT-Level Async-Signal-Safe _ Standard See \fBstandards\fR(7). .TE .sp .SH SEE ALSO .sp .LP \fBsigaction\fR(2), \fBsigpending\fR(2), \fBsigprocmask\fR(2), \fBsigsuspend\fR(2), \fBpthread_create\fR(3C), \fBpthread_kill\fR(3C), \fBpthread_sigmask\fR(3C), \fBsignal.h\fR(3HEAD), \fBattributes\fR(7), \fBstandards\fR(7) .SH NOTES .sp .LP The \fBsigwait()\fR function cannot be used to wait for signals that cannot be caught (see \fBsigaction\fR(2)). This restriction is silently imposed by the system. .sp .LP Prior to Oracle Solaris 11.4, the default compilation environment provided a definition of the \fBsigwait()\fR function as specified in POSIX.1c Draft 6. The final POSIX.1c standard changed the interface for \fBsigwait()\fR. To allow applications that were written to use the obsolete Draft-6 interfaces to continue to be compiled and run, the \fB__USE_DRAFT6_PROTOTYPES__\fR macro must be defined: .sp .in +2 .nf \fBcc\fR \fB-D__USE_DRAFT6_PROTOTYPES__\fR ... .fi .in -2 .sp .sp .LP Support for the Draft-6 interfaces is provided for source compatibility only and might not be supported in future releases. Old applications should be converted to use the standard definitions. .sp .LP Earlier implementations of these interfaces would not wake up on receiving a signal with a disposition of \fBSIG_IGN\fR.