Is 'sleep' based on the system clock or on time elapsed?
For example, if you execute:
sleep 1200
And immediately suspend your system for 10 minutes, will it end in another 10 minutes, or will it continue to wait for the full 20 minutes?
linuxosxsleep
Is 'sleep' based on the system clock or on time elapsed?
For example, if you execute:
sleep 1200
And immediately suspend your system for 10 minutes, will it end in another 10 minutes, or will it continue to wait for the full 20 minutes?
Best Answer
Well I guess it was easy enough to test. After initiating a 5 minute sleep, I suspended the system for about 2 minutes. The answer?
Sleep is calculated using elapsed time of the process, not clock time.
This may have been predictable since man sleep(3) says:
Which kind of implies the amount of time is internal to the sleep process.