Hello,
I have a real simple program that uses the POSIX create_timer() function, which is as follows-this code sample is standard and models other code samples that I've found on POSIX timer implementation:
Code:
void callback(union sigval sigev_value) { printf("In callback()\n"); }
void main()
{
int rc;
timer_t *timer_id;
struct sigevent evp;
memset((void *)&evp, 0, sizeof(evp));
timer_id = (timer_id*)malloc(sizeof(timer_id));
evp.sigev_notify_function = &callback;
evp.sigev_value.sival_ptr = (void*)timer_id;
errno = 0;
if (rc = timer_create(CLOCK_REALTIME, &evp, timer_id)) {
}
printf("timer_create() Rtn rc %d error %d\n", rc, errno);
perror("");
exit(rc);
}
But when I run it, I get the following output:
% timer
timer_create() Rtn rc -1 Error 0
Invalid Argument
What Invalid Argument? The arguments passed into timer_create are fine. It compiles OK. What could be the problem. Any ideas at all would be helpful.
Thanks,
dedham_ma_man