# Include <stdio. h> # Include <time. h> # Include <sys/time. h> # Include <stdlib. h> # Include <signal. h> Int sec; Void sigroutine (INT signo ){ Switch (signo ){ Case sigalrm: Printf ("catch a signal -- sigalrm \ n "); Signal (sigalrm, sigroutine ); Break; Case sigvtalrm: Printf ("catch a signal -- sigvtalrm \ n "); Signal (sigvtalrm, sigroutine ); Break; } Return; } Int main () { Struct itimerval value, ovalue, value2; // (1) SEC = 5; Printf ("process ID is % d \ n", getpid ()); Signal (sigalrm, sigroutine ); Signal (sigvtalrm, sigroutine ); Value. it_value. TV _sec = 1; Value. it_value. TV _usec = 0; Value. it_interval. TV _sec = 1; Value. it_interval. TV _usec = 0; Setitimer (itimer_real, & Value, & ovalue); // (2) Value2.it _ value. TV _sec = 0; Value2.it _ value. TV _usec = 500000; Value2.it _ interval. TV _sec = 0; Value2.it _ interval. TV _usec = 500000; Setitimer (itimer_virtual, & value2, & ovalue ); For (;;) ; } |