Skip to content

ProcessUNIX: Use monotonic clock in kwsysProcessTimeGetCurrent() for POSIX implementations

dublet requested to merge dublet/kwsys:monotonic-time into master

While a process is running, it is possible for other processes such as NTP to alter the system clock in large jumps.

To make the measurement of how long a process has taken to run impervious to such large jumps it is helpful to use a monotonic clock. This is a clock that takes an arbitrary starting point that does not change.

clock_gettime() is a POSIX method that implements this clock. This is not available on all platforms, so this commit adds a check for its presence. If the monotonic timer is available, use that in kwsysProcessTimeGetCurrent(), otherwise falls back to previous non-monotonic behaviour.

Edited by dublet

Merge request reports