home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJLSR201.ZIP / src / libc / posix / unistd / alarm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-15  |  539 b   |  20 lines

  1. /* Copyright (C) 1995 Charles Sandmann (sandmann@clio.rice.edu)
  2.    alarm() implmentation using setitimer 
  3.    This software may be freely distributed, no warranty. */
  4.  
  5. #include <libc/stubs.h>
  6. #include <unistd.h>
  7. #include <sys/time.h>
  8.  
  9. unsigned int alarm(unsigned int seconds)
  10. {
  11.   struct itimerval new_values;
  12.  
  13.   new_values.it_value.tv_sec = seconds;
  14.   new_values.it_value.tv_usec = 0;
  15.   new_values.it_interval.tv_sec = new_values.it_interval.tv_usec = 0;
  16.  
  17.   setitimer(ITIMER_REAL, &new_values, NULL);
  18.   return seconds;
  19. }
  20.