Date: Fri, 4 May 2018 14:39:32 +0000 (UTC) From: Alan Somers <asomers@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333251 - head/usr.bin/time Message-ID: <201805041439.w44EdWho045249@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: asomers Date: Fri May 4 14:39:32 2018 New Revision: 333251 URL: https://svnweb.freebsd.org/changeset/base/333251 Log: 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 Modified: head/usr.bin/time/time.c Modified: head/usr.bin/time/time.c ============================================================================== --- head/usr.bin/time/time.c Fri May 4 14:38:48 2018 (r333250) +++ head/usr.bin/time/time.c Fri May 4 14:39:32 2018 (r333251) @@ -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");
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201805041439.w44EdWho045249>