#include #include #include /* cranking the clock speed up too high causes problems with in handling the interrupts. Half-second seems good. */ #define CLOCK 1000 /* time between ticks: given in ms */ void NullRoutine() { signal(SIGALRM, NullRoutine); /* do nothing on an alarm, not the same as SIG_IGN */ } myclock(int ppid) { struct itimerval itimer; signal(SIGALRM, NullRoutine); /* do nothing on an alarm, not the same as SIG_IGN */ itimer.it_interval.tv_sec = CLOCK/1000; itimer.it_interval.tv_usec = (CLOCK*1000)%1000000; itimer.it_value.tv_sec = CLOCK/1000; itimer.it_value.tv_usec = (CLOCK*1000)%1000000; setitimer(ITIMER_REAL, &itimer, 0); while (1) { sigpause(0); kill(ppid, SIGALRM); } }