/* ** Set the alarm.
*/ void SetTimeOut(int nsec) { struct itimerval si;
if (nsec > 0) {
printf("#\n# Time out after %d seconds.\n", nsec); /* Set time after which timer expires. */
si.it_value.tv_sec = nsec; /* sec */
si.it_value.tv_usec = 0; /* msec */ /* The timer is not going to be reset. */
si.it_interval.tv_sec = 0;
si.it_interval.tv_usec = 0;
/* ** Switch on the time out mechanism. Check if the program has timed ** out in the mean time and if so terminate.
*/ void TimeOutOn(void) { if (TimeOutReached) {
printf("#\n# Process has timed out.\n#\n");
if (Gap) printf("];\n"); exit(0);
} else
DoTimeOut = 1;
}
/* ** Switch off the time out mechanism.
*/ void TimeOutOff(void) {
DoTimeOut = 0;
}
/* ** Catch the following signal in order to exit gracefully ** if the process is killed.
*/
signal(SIGHUP, handler);
signal(SIGINT, handler);
signal(SIGQUIT, handler);
signal(SIGABRT, handler);
signal(SIGTERM, handler); /* ** Catch the following signals to exit gracefully if the ** process crashes.
*/
signal(SIGILL, handler);
signal(SIGFPE, handler);
signal(SIGBUS, handler);
signal(SIGSEGV, handler); /* ** Catch the virtual alarm signal so that the process can time out.
*/
signal(SIGVTALRM, alarmClock);
}
/* ** return the cpu time in milli seconds
*/ #ifdef HAVE_GETRUSAGE
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.