HP-UX Reference (11i v2 07/12) - 2 System Calls (vol 5)

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 <signal.h>
#include <time.h>
timer_t timerid;
struct itimerspec one_minute = { {60, 0}, {0, 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,
overrun);
}
int main()
{
struct sigaction sigact;
struct sigevent sigev;
sigact.sa_handler = 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;
if (timer_create(CLOCK_REALTIME, &sigev, &timerid)
== -1) {
perror("timer_create");
exit(1);
}
if (timer_settime(timerid, 0, &one_minute, (struct itimerspec
== -1) {
476 Hewlett-Packard Company 3 HP-UX 11i Version 2: December 2007 Update