示例#1
0
/*
    Actual signal handler - must be async-safe. Do very, very little here. Just set a global flag and wakeup the wait
    service (mprWakeNotifier is async-safe). WARNING: Don't put memory allocation, logging or printf here.

    NOTES: The problems here are several fold. The signalHandler may be invoked re-entrantly for different threads for
    the same signal (SIGCHLD). Masked signals are blocked by a single bit and so siginfo will only store one such instance, 
    so you can't use siginfo to get the pid for SIGCHLD. So you really can't save state here, only set an indication that
    a signal has occurred. MprServiceSignals will then process. Signal handlers must then all be invoked and they must
    test if the signal is valid for them. 
 */
static void signalHandler(int signo, siginfo_t *info, void *arg)
{
    MprSignalService    *ssp;
    MprSignalInfo       *ip;
    int                 saveErrno;

    if (signo <= 0 || signo >= MPR_MAX_SIGNALS || MPR == 0) {
        return;
    }
    if (signo == SIGINT) {
        exit(1);
        return;
    }
    ssp = MPR->signalService;
    ip = &ssp->info[signo];
    ip->triggered = 1;
    ssp->hasSignals = 1;
    saveErrno = errno;
    mprWakeNotifier();
    errno = saveErrno;
}
示例#2
0
PUBLIC void mprWakeEventService()
{
    if (MPR->eventService->waiting) {
        mprWakeNotifier();
    }
}