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
This commit is contained in:
parent
6d5127daf4
commit
8a9ab04279
@ -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");
|
||||
|
Loading…
Reference in New Issue
Block a user