Messages in this thread | | | Date | Wed, 20 Mar 1996 17:28:01 -0500 | From | "Jin S. Choi" <> | Subject | setitimer() not working in 1.3.76? |
| |
I found while trying to compile the benchmarks that come with the glibc crypt implementation that itimers don't appear to be working. I've attached a test case. It should count down from 2 to 0 then print "All done!" and exit. For me, it loops printing "we should be done". On my friend's machine running 1.3.68, it does the right thing.
---------------------------------------------------------------------- #include <signal.h> #include <stdio.h> #include <sys/time.h>
void Stop () { printf ("All done!\n"); exit (0); }
int main() { struct itimerval itv; int i; int old;
signal(SIGVTALRM, Stop); itv.it_value.tv_sec = 2; itv.it_value.tv_usec = 0; setitimer(ITIMER_VIRTUAL, &itv, NULL); old = 2; for (i = 0; ; i++) { struct itimerval iv; getitimer(ITIMER_VIRTUAL, &iv); if (iv.it_value.tv_sec != old) { old = iv.it_value.tv_sec; printf("%d\n", old); } if (old == 0 && iv.it_value.tv_usec == 0) { printf("we should be done!\n"); } } }
| |