Movatterモバイル変換


[0]ホーム

URL:


man7.org > Linux >man-pages

Linux/UNIX system programming training


sigwait(3p) — Linux manual page

PROLOG |NAME |SYNOPSIS |DESCRIPTION |RETURN VALUE |ERRORS |EXAMPLES |APPLICATION USAGE |RATIONALE |FUTURE DIRECTIONS |SEE ALSO |COPYRIGHT

SIGWAIT(3P)             POSIX Programmer's ManualSIGWAIT(3P)

PROLOG        top

       This manual page is part of the POSIX Programmer's Manual.  The       Linux implementation of this interface may differ (consult the       corresponding Linux manual page for details of Linux behavior), or       the interface may not be implemented on Linux.

NAME        top

       sigwait — wait for queued signals

SYNOPSIS        top

       #include <signal.h>       int sigwait(const sigset_t *restrictset, int *restrictsig);

DESCRIPTION        top

       Thesigwait() function shall select a pending signal fromset,       atomically clear it from the system's set of pending signals, and       return that signal number in the location referenced bysig.  If       prior to the call tosigwait() there are multiple pending       instances of a single signal number, it is implementation-defined       whether upon successful return there are any remaining pending       signals for that signal number.  If the implementation supports       queued signals and there are multiple signals queued for the       signal number selected, the first such queued signal shall cause a       return fromsigwait() and the remainder shall remain queued. If no       signal inset is pending at the time of the call, the thread shall       be suspended until one or more becomes pending. The signals       defined byset shall have been blocked at the time of the call tosigwait(); otherwise, the behavior is undefined. The effect ofsigwait() on the signal actions for the signals inset is       unspecified.       If more than one thread is usingsigwait() to wait for the same       signal, no more than one of these threads shall return fromsigwait() with the signal number. If more than a single thread is       blocked insigwait() for a signal when that signal is generated       for the process, it is unspecified which of the waiting threads       returns fromsigwait().  If the signal is generated for a specific       thread, as bypthread_kill(), only that thread shall return.       Should any of the multiple pending signals in the range SIGRTMIN       to SIGRTMAX be selected, it shall be the lowest numbered one. The       selection order between realtime and non-realtime signals, or       between multiple pending non-realtime signals, is unspecified.

RETURN VALUE        top

       Upon successful completion,sigwait() shall store the signal       number of the received signal at the location referenced bysig       and return zero. Otherwise, an error number shall be returned to       indicate the error.

ERRORS        top

       Thesigwait() function may fail if:EINVALTheset argument contains an invalid or unsupported signal              number.The following sections are informative.

EXAMPLES        top

       None.

APPLICATION USAGE        top

       None.

RATIONALE        top

       To provide a convenient way for a thread to wait for a signal,       this volume of POSIX.1‐2017 provides thesigwait() function. For       most cases where a thread has to wait for a signal, thesigwait()       function should be quite convenient, efficient, and adequate.       However, requests were made for a lower-level primitive thansigwait() and for semaphores that could be used by threads. After       some consideration, threads were allowed to use semaphores andsem_post() was defined to be async-signal-safe.       In summary, when it is necessary for code run in response to an       asynchronous signal to notify a thread,sigwait() should be used       to handle the signal. Alternatively, if the implementation       provides semaphores, they also can be used, either followingsigwait() or from within a signal handling routine previously       registered withsigaction().

FUTURE DIRECTIONS        top

       None.

SEE ALSO        top

Section 2.4,Signal Concepts,Section 2.8.1,Realtime Signals,pause(3p),pthread_sigmask(3p),sigaction(3p),sigpending(3p),sigsuspend(3p),sigtimedwait(3p)       The Base Definitions volume of POSIX.1‐2017,signal.h(0p),time.h(0p)

COPYRIGHT        top

       Portions of this text are reprinted and reproduced in electronic       form from IEEE Std 1003.1-2017, Standard for Information       Technology -- Portable Operating System Interface (POSIX), The       Open Group Base Specifications Issue 7, 2018 Edition, Copyright       (C) 2018 by the Institute of Electrical and Electronics Engineers,       Inc and The Open Group.  In the event of any discrepancy between       this version and the original IEEE and The Open Group Standard,       the original IEEE and The Open Group Standard is the referee       document. The original Standard can be obtained online athttp://www.opengroup.org/unix/online.html .       Any typographical or formatting errors that appear in this page       are most likely to have been introduced during the conversion of       the source files to man page format. To report such errors, seehttps://www.kernel.org/doc/man-pages/reporting_bugs.html .IEEE/The Open Group                2017SIGWAIT(3P)

Pages that refer to this page:signal.h(0p)sigtimedwait(3p)



HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface.

For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere.

Hosting byjambit GmbH.

Cover of TLPI


[8]ページ先頭

©2009-2025 Movatter.jp