int run(void *pArg) { int sig_num ; OsStatus res ; // Wait for a signal. This will unblock signals // for THIS thread only, so this will be the only thread // to catch an async signal directed to the process // from the outside. res = awaitSignal(sig_num); if (res == OS_SUCCESS) { if (SIGTERM == sig_num) { OsSysLog::add( LOG_FACILITY, PRI_INFO, "SignalTask: terminate signal received."); } else { OsSysLog::add( LOG_FACILITY, PRI_CRIT, "SignalTask: caught signal: %d", sig_num ); } } else { OsSysLog::add( LOG_FACILITY, PRI_CRIT, "SignalTask: awaitSignal() failed"); } // set the global shutdown flag gShutdownFlag = TRUE ; return 0 ; }
int run(void *pArg) { int sig_num; OsStatus res; // Wait for a signal. This will unblock signals // for THIS thread only, so this will be the only thread // to catch an async signal directed to the process // from the outside. while (!gbDone) { res = awaitSignal(sig_num); if (res != OS_SUCCESS) { Os::Logger::instance().log(FAC_SUPERVISOR, PRI_ALERT, "awaitSignal() errno=%d", errno); } // Call the original signal handler. Pass -1 on error from awaitSignal sig_routine(OS_SUCCESS == res ? sig_num : -1); } return 0; }