tags:

views:

464

answers:

1

I currently have some C code that uses sigaction to associate a handler to the SIGALRM signal. Then I do alarm(TIME_OUT_IN_SECONDS). Problem is, I need milliseconds, not seconds and alarm takes an integer. How can I set the signal to fire off in milliseconds?

+2  A: 

How about using setitimer()?

jpalecek
Thanks, the examples I had seen with setitimer() were all associated with signal() and not sigaction so I wasn't sure if they were compatible. As you can tell, I'm a C newbie :)
Tim Merrifield
Ah so... You shouldn't worry about this, signal() and sigactions() are just interfaces for the same function.
jpalecek
But sigaction() should be preferred over signal() for portability issues.
Raim
AFAIK, it's not for portability issues, but to avoid some races the use of the signal() function normally creates.
jpalecek