Home | History | Annotate | Line # | Download | only in ras3
ras3.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;
     12 struct itimerval itv;
     13 
     14 void handler(int);
     15 
     16 void
     17 handler(int sig)
     18 {
     19 
     20 	handled++;
     21 }
     22 
     23 int
     24 main(int argc, char *argv[])
     25 {
     26 	int rv;
     27 	char *const args[] = { argv[0], "1", NULL };
     28 
     29         signal(SIGVTALRM, handler);
     30 
     31         itv.it_interval.tv_sec = 0;
     32         itv.it_interval.tv_usec = 0;
     33         itv.it_value.tv_sec = 10;
     34         itv.it_value.tv_usec = 0;
     35         setitimer(ITIMER_VIRTUAL, &itv, NULL);
     36 
     37 	if (argc != 2) {
     38 		if (rasctl((caddr_t)&&start, (caddr_t)&&end - (caddr_t)&&start,
     39 		    RAS_INSTALL) < 0)
     40 			return (1);
     41 		if (fork() != 0) {
     42 			wait(&rv);
     43 			return (rv == 0);
     44 		}
     45 		if (execvp(argv[0],args) < 0) {
     46 			printf("exec failed\n");
     47 			return (0);
     48 		}
     49 	}
     50 
     51 start:
     52 	count++;
     53 	if (count > COUNT)
     54 		goto end;
     55 
     56 	while (!handled) {
     57 		continue;
     58 	}
     59 end:
     60 
     61 	return (handled != 0);
     62 }
     63