bug with setitimer on 4.2 BSD?

mr-frog at sdcsvax.UUCP mr-frog at sdcsvax.UUCP
Sat Mar 31 01:05:06 AEST 1984


:
I've been experimenting recently with the system call setitimer,
and I was quite distressed to find that after several successive
calls (around 300 or so) it stopped working!  What the call is supposed
to do is to send the process an alarm (SIGALRM) when an appropriate
number of microseconds have passed.  It worked just fine for a while,
but at some (seemingly random) point it simply doesn't send that
SIGALRM, and the program waiting for it hangs.

Am I using setitimer properly?

Here is the code I ran to test and duplicate the problem:
/*************************************************************************/
#include <stdio.h>
#include <sys/time.h>
#include <signal.h>

struct	itimerval timer;
int		wakeup;

main() {
	int	alarmtrap();
	register int i;

	signal(SIGALRM, alarmtrap);
	timer.it_interval.tv_sec = 0;
	timer.it_interval.tv_usec = 0;
	timer.it_value.tv_sec = 0;
	wakeup = 0;
	for (i=0; i<1000; i++) {
		timer.it_value.tv_usec = 30000;
		setitimer(ITIMER_REAL, &timer, NULL);
		sigpause(0);
		printf("alarm %d\n", wakeup);
	}
}

alarmtrap() {
	wakeup++;
}
/*******************************************************************/


Dave Pare
ucbvax!sdcsvax!mr-frog



More information about the Comp.unix.wizards mailing list