home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / unix / unixlib_1 / !UnixLib37_src_sys_c_alarm < prev    next >
Encoding:
C/C++ Source or Header  |  1996-11-09  |  1.1 KB  |  37 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/sys/c/RCS/alarm,v $
  4.  * $Date: 1996/10/30 21:59:00 $
  5.  * $Revision: 1.3 $
  6.  * $State: Rel $
  7.  * $Author: unixlib $
  8.  *
  9.  * $Log: alarm,v $
  10.  * Revision 1.3  1996/10/30 21:59:00  unixlib
  11.  * Massive changes made by Nick Burret and Peter Burwood.
  12.  *
  13.  * Revision 1.2  1996/05/06 09:01:34  unixlib
  14.  * Updates to sources made by Nick Burrett, Peter Burwood and Simon Callan.
  15.  * Saved for 3.7a release.
  16.  *
  17.  * Revision 1.1  1996/04/19 21:34:24  simon
  18.  * Initial revision
  19.  *
  20.  ***************************************************************************/
  21.  
  22. static const char rcs_id[] = "$Id: alarm,v 1.3 1996/10/30 21:59:00 unixlib Rel $";
  23.  
  24. #include <unistd.h>
  25. #include <sys/time.h>
  26.  
  27. unsigned int
  28. alarm (unsigned int seconds)
  29. {
  30.   struct itimerval old, new_timer;
  31.   new_timer.it_interval.tv_usec = 0;
  32.   new_timer.it_interval.tv_sec = 0;
  33.   new_timer.it_value.tv_usec = 0;
  34.   new_timer.it_value.tv_sec = (int) seconds;
  35.   return (setitimer (ITIMER_REAL, &new_timer, &old) < 0) ? 0 : old.it_value.tv_sec;
  36. }
  37.