Back to index

glibc  2.9
Functions
alarm.c File Reference
#include <unistd.h>
#include <sys/time.h>

Go to the source code of this file.

Functions

unsigned int alarm (unsigned int seconds)

Function Documentation

unsigned int alarm ( unsigned int  seconds)

Definition at line 30 of file alarm.c.

{
  struct itimerval old, new;
  unsigned int retval;

  new.it_interval.tv_usec = 0;
  new.it_interval.tv_sec = 0;
  new.it_value.tv_usec = 0;
  new.it_value.tv_sec = (long int) seconds;
  if (__setitimer (ITIMER_REAL, &new, &old) < 0)
    return 0;

  retval = old.it_value.tv_sec;
  /* Round to the nearest second, but never report zero seconds when
     the alarm is still set.  */
  if (old.it_value.tv_usec >= 500000
      || (retval == 0 && old.it_value.tv_usec > 0))
    ++retval;
  return retval;
}

Here is the call graph for this function: