You could implement the following:
Setup your signal handler with sigaction
, ensuring the handler's signature is void handler(int, siginfo_t*, void*)
.
Create a number of timers with timer_create
, each specifying a different sigevent
structure (in particular the sigev_value
).
In the signal handler, process the siginfo_t
structure and use either of the following fields to determine which timer expired si_int
, si_ptr
(one of these will correspond to the sigev_value
in step 2) or use si_timerid
. Of course, if you use the si_timerid
field, there's no need to define sigev_value
in step 2.
That way, the signal handler can identify which timer triggered the signal and can appropriate action.