lkml.org 
[lkml]   [1996]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectsetitimer() 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");
}
}
}


\
 
 \ /
  Last update: 2005-03-22 13:36    [W:0.036 / U:0.780 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site