I have various processes that need to know how long they’ve been
running. They make use of the clock() function which “returns the
number of clock ticks of processor time used by the program since
it started executing.”
The main application allows the user to change the system date
and time. It does a system call of ‘date’ and ‘rtc’ to change the
date and time.
However, once this is done, the clock() function isn’t doing what
it says it does. The change of the system date/time changes the
value clock() returns, so that it’s no longer the “number of clock
ticks of processor time used by the program since it started
executing”. Its returning that PLUS the difference of any time
adjustments to the system clock. ie. I change the time ahead 1
hour, and clock() starts returning what it should + 3600.
So, the documentation’s wrong, or the clock() function is buggy.
Are there any alternatives that you can suggest? I’d rather
not call ‘date’ and ‘rtc’ with a system() call, so alternatives
to that would be appreciated as well.
In summary, I need to be able to know how long a process has
been running, regardless of time/date changes by the user.
Thanks for the help,
Barry