1 /* alarm.c 4.2 84/03/22 */ 2 3 /* 4 * Backwards compatible alarm. 5 */ 6 #include <sys/time.h> 7 8 alarm(secs) 9 int secs; 10 { 11 struct itimerval it, oitv; 12 register struct itimerval *itp = ⁢ 13 14 timerclear(&itp->it_interval); 15 itp->it_value.tv_sec = secs; 16 itp->it_value.tv_usec = 0; 17 if (setitimer(ITIMER_REAL, itp, &oitv) < 0) 18 return (-1); 19 if (oitv.it_value.tv_usec) 20 oitv.it_value.tv_sec++; 21 return (oitv.it_value.tv_sec); 22 } 23