PosixSignalManagerImpl.cpp
//==============================================================================
// Safely tests and resets the delivery status of a signal.  Delivery status of
// the signal is returned and the delivery status itself is reset to indicate
// that the signal is no longer delivered.
//==============================================================================
Safely tests and resets the delivery status of a signal.  Delivery status of
the signal is returned and the delivery status itself is reset to indicate
that the signal is no longer delivered.
Safely tests and resets the delivery status of a signal . Delivery status of the signal is returned and the delivery status itself is reset to indicate that the signal is no longer delivered .
bool PosixSignalManagerImpl::isSignalDelivered(int sig)
{
    bool sig_delivered = false;
    bool out_of_range = false;
    std::out_of_range out_of_range_ex("");
    sigset_t block_sig;
    sigemptyset(&block_sig);
    sigaddset(&block_sig, sig);
    sigprocmask(SIG_BLOCK, &block_sig, 0);
    try
    {
        sig_delivered = signals.at(sig).delivery_status == DELIVERED;
        signals.at(sig).delivery_status = NOT_DELIVERED;
    }
    catch (std::out_of_range& ex)
    {
        out_of_range = true;
        out_of_range_ex = ex;
    }
    sigprocmask(SIG_UNBLOCK, &block_sig, 0);
    if (out_of_range)
    {
        throw out_of_range_ex;
    }
    return sig_delivered;
}
bool PosixSignalManagerImpl :: isSignalDelivered ( int sig ) { bool sig_delivered = false ; bool out_of_range = false ; std :: out_of_range out_of_range_ex ( " " ) ; sigset_t block_sig ; sigemptyset ( & block_sig ) ; sigaddset ( & block_sig , sig ) ; sigprocmask ( SIG_BLOCK , & block_sig , 0 ) ; try { sig_delivered = signals . at ( sig ) . delivery_status == DELIVERED ; signals . at ( sig ) . delivery_status = NOT_DELIVERED ; } catch ( std :: out_of_range & ex ) { out_of_range = true ; out_of_range_ex = ex ; } sigprocmask ( SIG_UNBLOCK , & block_sig , 0 ) ; if ( out_of_range ) { throw out_of_range_ex ; } return sig_delivered ; }
Safely tests and resets the delivery status of a signal.
Safely tests and resets the delivery status of a signal .
// Disable signals of type sig while we test and reset the current delivery // status of sig // This will toss an exception if sig is unknown to us.  We can't let it // propagate up because we have to finish our work here and reset the // signal mask before allowing anything else to happen.  We'll re-throw // any exceptions that happen here later. // Reset the deliery flag for this signal // Start allowing signals of type sig again // If we got an out_of_range exception earlier re-throw it