Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interrupt sleep() function

Tags:

c++

How can I interrupt sleep() using a signal handler?

like image 901
sleep Avatar asked Jul 01 '10 11:07

sleep


1 Answers

From sleep() function man page:

The sleep() function suspends execution of the calling thread until either seconds seconds have elapsed or a signal is delivered to the thread and its action is to invoke a signal-catching function or to terminate the thread or process. System activity may lengthen the sleep by an indeterminate amount.

So, if a signal is send to the application, its execution is resumed from the instruction after the sleep call.

like image 142
kist Avatar answered Nov 08 '22 14:11

kist