Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pausing a timer using setitimer?

Tags:

c

timer

setitimer

In C, is there a way to start a timer using setitimer, then pause it, then resume the timer with the time remaining when it was paused? My initial thought was to save the time left by using getitimer, stop the timer, then set the timer back to the saved value in getitimer, but this doesn't seem to be working.

like image 405
Anthony C. Avatar asked Feb 23 '26 02:02

Anthony C.


1 Answers

You cannot pause a timer. Saving the time remaining, stopping the timer and then starting a new timer is the way to do this. That method does work so I guess you have a bug in your code.

like image 89
David Heffernan Avatar answered Feb 24 '26 20:02

David Heffernan