alarm.c raw

   1  #include <unistd.h>
   2  #include <sys/time.h>
   3  #include "syscall.h"
   4  
   5  unsigned alarm(unsigned seconds)
   6  {
   7  	struct itimerval it = { .it_value.tv_sec = seconds }, old = { 0 };
   8  	setitimer(ITIMER_REAL, &it, &old);
   9  	return old.it_value.tv_sec + !!old.it_value.tv_usec;
  10  }
  11