timers.2 (2010 09)
t
timers(2) timers(2)
[EFAULT] The timerid or evp argument points to an invalid address.
[ENOSYS] The function
timer_create()
is not supported by this implementation.
If any of the following conditions occur, the
timer_delete() function returns −1 and sets
errno to
the corresponding value:
[EINVAL] The timer ID specified by timerid is not a valid timer ID.
[ENOSYS] The function
timer_delete()
is not supported by this implementation.
If any of the following conditions occur, the
timer_settime(),
timer_gettime(), and
timer_getoverrun()
functions return − 1 and set errno
to the corresponding value:
[EINVAL] The timerid argument does not correspond to an ID returned by
timer_create()
,
but not yet deleted by
timer_delete()
.
[EINVAL] The value structure passed to
timer_settime()
specified a nanosecond value less
than zero or greater than or equal to 1000 million.
[EFAULT] The value or ovalue argument points to an invalid address.
[ENOSYS] The
timer_settime()
, timer_gettime()
, and timer_getoverrun()
func-
tions are not supported by this implementation.
EXAMPLES
Create a timer, set it to go off in one minute, and deliver a
SIGUSR1 signal:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <time.h>
timer_t timerid;
struct itimerspec one_minute = {0} ;
void handler()
{
int overrun = timer_getoverrun(timerid);
if (overrun == -1) {
perror("handler: timer_getoverrun()");
exit(1);
}
(void)printf("Timer expired, overrun count was %d\n",
overrun);
}
int main()
{
struct sigaction sigact;
struct sigevent sigev;
one_minute.it_interval.tv_sec = 0;
one_minute.it_interval.tv_nsec = 0;
one_minute.it_value.tv_sec = 60;
one_minute.it_value.tv_nsec = 0;
sigact.sa_handler = (void (*)(int))handler;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
if (sigaction(SIGUSR1, &sigact, (struct sigaction *)NULL)
== -1) {
perror("sigaction");
exit(1);
}
sigev.sigev_notify = SIGEV_SIGNAL;
sigev.sigev_signo = SIGUSR1;
HP-UX 11i Version 3: September 2010 − 3 − Hewlett-Packard Company 3