A safer alternative to setitimer (which POSIX 2008 stands for OBS olete) will use POSIX timers and use the expiration function of the timer in the stream rather than the signal handler. Thus, you are not limited to using functions that support async signal. They are described here:
http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_08_05
If you don't like the POSIX Timer API, you can create a thread that just sleeps in a loop and block the timer signal in all threads except this thread. Then you can freely use any functions that you like in the signal handler, because they will work in a separate stream, and there is no danger that it interrupts the function of the non-synchronizing signal of the asynchronous signal.
source share