Go to the first, previous, next, last section, table of contents.


setitimer

Syntax

#include <sys/time.h>

struct itimerval {
  struct timeval it_interval;    /* timer interval */
  struct timeval it_value;       /* current value */
};

int setitimer(int which, struct itimerval *value, struct itimerval *ovalue);

Description

Each process has two interval timers, ITIMER_REAL and ITIMER_PROF, which signal SIGALRM and SIGPROF respectively. These are typically used to provide alarm() and profiling capabilities.

This function changes the current value of the interval timer specified by which to the values in structure value. The previous value of the timer is returned if ovalue is not NULL. When the timer expires the appropriate signal is raised.

A timer is defined by the itimerval structure. If it_value is non-zero it specifies the time to the next timer expiration. If it_interval is non-zero it specifies the value to reload into it_value on timer expiration. Setting it_value to zero disables a timer. Setting it_interval to zero causes the timer to only happen once instead of repeating.

Although times can be given with microsecond resolution, the granularity is determined by the timer interrupt frequency.

This version uses section uclock to determine the time of expiration. Under Windows 95, this fails because the OS reprograms the timer. Also, most debuggers cannot cope with hardware interrupts and report SIGSEGV, or SIGABRT.

Return Value

Returns 0 on success, -1 on failure (and sets errno).

Portability

not ANSI, not POSIX


Go to the first, previous, next, last section, table of contents.