So this question is really "Why are time.h not the same on OS X and Linux?" but, I've made my peace with those differences.
To create timers on a 'Unix' system, I followed this tutorial http://www.helsinki.fi/atk/unix/dec_manuals/DOC_40D/APS33DTE/DOCU_007.HTM#timer-type-sec
which requires the use of <sys/time.h>
and calling timer_create()
, then setting up a signal handler for the signal type. This I know how to do. The question is, how is the same thing achieved on OS X?
The key thing to note is that these timers need to be realtime, that is, asynchronously queued and must use the sa_sigaction
field of a struct sigaction
, so that metadata associated with the timer alarm can be passed to the signal handler. This is described in more detail here http://www.helsinki.fi/atk/unix/dec_manuals/DOC_40D/APS33DTE/DOCU_006.HTM#sigevent-sec.
Have you looked into setitimer()
?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With