#include	<unistd.h>
#include	<signal.h> 
#include	<sys/time.h> 
#define TIMERCNT 8 
void		timerhandler(); 
int		timercnt; 
struct 		timeval		alarmtimes[TIMERCNT]; 
main(argc, argv)
     int 			argc; 
     char 			*argv[]
{ 
    struct itimerval		times; 
    sigset_t   sigset; 
    int   	i; 
    /* block SIGALRM */ 
    sigemptyset(&sigset); 
    sigaddset(&sigset, SIGALRM); 
	sigprocmask(SIG_BLOCK, &sigset, NULL); 
    /* set up handler for SIGALRM */ 
    signal(SIGALRM, timerhandler); 
	/*
     * set up interval timer, starting in three seconds,
     * then every 1/3 second
     */
     times.it_value.tv_sec = 3;
     times.it_value.tv_usec = 0;
     times.it_interval.tv_sec = 0;
     times.it_interval.tv_usec = 333333;
     setitimer (ITIMER_REAL, &times, NULL);/
     /* now wait for the alarm */
     timehandler(0, 0, NULL, NULL);
     while (timercnt < TIMERCNT) {
 		sigsuspend (sigset);
     }
 	 printtimes();
}
void
timehandler(sig, code, scp, addr)
     int        sig, code;
     struct 				sigcontext*scp;
     char     				*addr;
{
     gettimeofday(&alarmtimes[timercnt], NULL);
     timercnt++;
}
printtimes()
{
     int     i;
     for (i=0; i <TIMERCNT; i++) {
          printf("%d.%06d0, alarmtimes[i].tv_sec,
                    alarmtimes[i].tv_usec);
     }
}
