diff options
author | des <des@FreeBSD.org> | 2003-05-01 16:59:23 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2003-05-01 16:59:23 +0000 |
commit | 8ed712ead15fc26b5070dcac9458f31fc6ecf0fa (patch) | |
tree | d8221c44ce99320f82809d2b7504a757957a47c4 /sys/kern/kern_acct.c | |
parent | eaf3fff90a28f606675fd3c1610d0def28d6be67 (diff) | |
download | FreeBSD-src-8ed712ead15fc26b5070dcac9458f31fc6ecf0fa.zip FreeBSD-src-8ed712ead15fc26b5070dcac9458f31fc6ecf0fa.tar.gz |
Instead of recording the Unix time in a process when it starts, record the
uptime. Where necessary, convert it back to Unix time by adding boottime
to it. This fixes a potential problem in the accounting code, which would
compute the elapsed time incorrectly if the Unix time was stepped during
the lifetime of the process.
Diffstat (limited to 'sys/kern/kern_acct.c')
-rw-r--r-- | sys/kern/kern_acct.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/kern_acct.c b/sys/kern/kern_acct.c index 9de4641..19e5b1c 100644 --- a/sys/kern/kern_acct.c +++ b/sys/kern/kern_acct.c @@ -250,8 +250,10 @@ acct_process(td) acct.ac_stime = encode_comp_t(st.tv_sec, st.tv_usec); /* (3) The elapsed time the command ran (and its starting time) */ - acct.ac_btime = p->p_stats->p_start.tv_sec; - microtime(&tmp); + tmp = boottime; + timevaladd(&tmp, &p->p_stats->p_start); + acct.ac_btime = tmp.tv_sec; + microuptime(&tmp); timevalsub(&tmp, &p->p_stats->p_start); acct.ac_etime = encode_comp_t(tmp.tv_sec, tmp.tv_usec); |