Reputation: 43
Code is like this.In some situation, eagain is returned.
struct sigevent sev;
sev.sigev_notify = SIGEV_THREAD_ID;
sev._sigev_un._tid = syscall(SYS_gettid);
sev.sigev_signo = alarm_signal();
r = timer_create(CLOCK_MONOTONIC, &sev, &_steady_clock_timer);
assert(r >= 0);
In the man, EGAIN is returned in two situation,
EAGAIN
The system lacks sufficient signal queuing resources to honor the request.
EAGAIN
The calling process has already created all of the timers it is allowed by
this implementation.
the first situation, in our machine, ulimit -i is 2061776, it can not reach this limit.
What is the timer limit said by the second situation and how to find it?
Upvotes: 1
Views: 228
Reputation: 142585
You have to handle the EAGAIN
case here.
timer_create()
's implementation does two allocation during system call handling. It could happen in cases if a) timer allocation or b) sigqueue allocation failure.
Another things to look at is finding the running task's sigpending
size. It is possible to increase the running task's RLIMIT_SIGPENDING
(man setrlimit
). Changing with ulimit
will affect only to the shell and the process started by it, therefore it might have no direct impact on your application.
Upvotes: 1
Reputation: 8563
Try making the following change:
struct sigevent sev;
memset(&sev, 0, sizeof(sev));
It is possible that there's an aspect of sigevent
that gets initialized to something that breaks the timer allocation.
Upvotes: 0