About the ambiguous description of sigwait()

前端 未结 2 501
臣服心动
臣服心动 2020-12-09 04:38

If no signal in set is pending at the time of the call, the thread shall be suspended until one or more becomes pending. The signals defined by s

2条回答
  •  清歌不尽
    2020-12-09 04:55

    From the signal(7) man page:

    Signal Mask and Pending Signals
        A  signal  may  be  blocked,  which means that it will not be delivered
        until it is later unblocked.  Between the time when it is generated and
        when it is delivered a signal is said to be pending.
    

    "Pending" and "blocked" are not mutually exclusive.

    Also from the signal(7) man page:

    Synchronously Accepting a Signal
        Rather than asynchronously catching a signal via a signal  handler,  it
        is  possible to synchronously accept the signal, that is, to block exe-
        cution until the signal is delivered, at which point the kernel returns
        information about the signal to the caller.  There are two general ways
        to do this:
    
        * sigwaitinfo(2), sigtimedwait(2),  and  sigwait(3)  suspend  execution
          until  one  of  the signals in a specified set is delivered.  Each of
          these calls returns information about the delivered signal.
    

    So sigaction() is used to allow other code to run until a signal is pending, whereas sigwait() suspends execution of the thread until a signal is pending but blocked.

提交回复
热议问题