aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Somers <asomers@FreeBSD.org>2018-05-04 14:39:32 +0000
committerAlan Somers <asomers@FreeBSD.org>2018-05-04 14:39:32 +0000
commit8a9ab04279e6d01527cf90aae92835d56603ce52 (patch)
tree493acc68de34a63046ae2690facb71d9eb1a2f80
parent6d5127daf437765aed9e9efcc85625d62fdf7b5b (diff)
downloadsrc-8a9ab04279e6d01527cf90aae92835d56603ce52.tar.gz
src-8a9ab04279e6d01527cf90aae92835d56603ce52.zip
time(1): use the monotonic clock
The monotonic clock is more appropriate than the realtime clock for measuring durations. Reviewed by: ken, jilles Differential Revision: https://reviews.freebsd.org/D14032
Notes
Notes: svn path=/head/; revision=333251
-rw-r--r--usr.bin/time/time.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c
index 02c67ad19914..9121b1f14408 100644
--- a/usr.bin/time/time.c
+++ b/usr.bin/time/time.c
@@ -121,7 +121,7 @@ main(int argc, char **argv)
setvbuf(out, (char *)NULL, _IONBF, (size_t)0);
}
- if (clock_gettime(CLOCK_REALTIME, &before_ts))
+ if (clock_gettime(CLOCK_MONOTONIC, &before_ts))
err(1, "clock_gettime");
switch(pid = fork()) {
case -1: /* error */
@@ -141,13 +141,13 @@ main(int argc, char **argv)
while (wait4(pid, &status, 0, &ru) != pid) {
if (siginfo_recvd) {
siginfo_recvd = 0;
- if (clock_gettime(CLOCK_REALTIME, &after))
+ if (clock_gettime(CLOCK_MONOTONIC, &after))
err(1, "clock_gettime");
getrusage(RUSAGE_CHILDREN, &ru);
showtime(stdout, &before_ts, &after, &ru);
}
}
- if (clock_gettime(CLOCK_REALTIME, &after))
+ if (clock_gettime(CLOCK_MONOTONIC, &after))
err(1, "clock_gettime");
if ( ! WIFEXITED(status))
warnx("command terminated abnormally");