Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting an alarm in milliseconds in C

Tags:

c

signals

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?

like image 367
Tim Merrifield Avatar asked Mar 02 '09 01:03

Tim Merrifield


People also ask

What does SIGALRM do?

SIGALRM is an asynchronous signal. The SIGALRM signal is raised when a time interval specified in a call to the alarm or alarmd function expires. Because SIGALRM is an asynchronous signal, the SAS/C library discovers the signal only when you call a function, when a function returns, or when you issue a call to sigchk .


1 Answers

How about using setitimer()?

like image 158
jpalecek Avatar answered Sep 22 '22 12:09

jpalecek