ras2.c revision 1.1
1#include <stdio.h> 2#include <signal.h> 3#include <unistd.h> 4#include <sys/ras.h> 5#include <sys/time.h> 6#include <sys/wait.h> 7 8#define COUNT 10 9 10__volatile int handled = 0; 11__volatile int count = 0; 12struct itimerval itv; 13 14void handler(int); 15 16void 17handler(int sig) 18{ 19 20 handled++; 21} 22 23int 24main(void) 25{ 26 int rv; 27 28 signal(SIGVTALRM, handler); 29 30 itv.it_interval.tv_sec = 0; 31 itv.it_interval.tv_usec = 0; 32 itv.it_value.tv_sec = 10; 33 itv.it_value.tv_usec = 0; 34 setitimer(ITIMER_VIRTUAL, &itv, NULL); 35 36 if (rasctl((caddr_t)&&start, (caddr_t)&&end - (caddr_t)&&start, 37 RAS_INSTALL) < 0) 38 return (1); 39 40 if (fork() != 0) { 41 wait(&rv); 42 return (rv); 43 } 44 45start: 46 count++; 47 if (count > COUNT) 48 goto end; 49 50 while (!handled) { 51 continue; 52 } 53end: 54 55 return (handled != 0); 56} 57