void set_an_alarm(void) { struct timeval delta; int nextalarm = get_next_alarm_delay_time(&delta); /* * * We don't use signals if they asked us nicely not to. It's expected * * they'll check the next alarm time and do their own calling of * * run_alarms(). * */ if(nextalarm) { struct itimerval it; it.it_value.tv_sec = delta.tv_sec; it.it_value.tv_usec = delta.tv_usec; it.it_interval.tv_sec = 0; it.it_interval.tv_usec = 0; signal(SIGALRM, alarm_handler); setitimer(ITIMER_REAL, &it, NULL); printf("schedule alarm %d in %d.%03d seconds\n", nextalarm, (int) delta.tv_sec, (int) (delta.tv_usec / 1000)); } else { printf("no alarms found to schedule\n"); } }
void set_an_alarm(void) { int nexttime = get_next_alarm_delay_time(); /* we don't use signals if they asked us nicely not to. It's expected they'll check the next alarm time and do their own calling of run_alarms(). */ if (!ds_get_boolean(DS_LIBRARY_ID, DS_LIB_ALARM_DONT_USE_SIG) && nexttime) { #ifndef WIN32 #ifdef SIGALRM //FIXMEHMTHMT alarm(nexttime); DEBUGMSGTL(("snmp_alarm_set_an_alarm","setting an alarm for %d seconds from now\n",nexttime)); signal(SIGALRM, alarm_handler); #endif /* SIGALRM */ #endif } else { DEBUGMSGTL(("snmp_alarm_set_an_alarm","no alarms found to handle\n")); } }