From owner-svn-src-head@freebsd.org Fri May 4 14:39:32 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AE30AFAF0DC; Fri, 4 May 2018 14:39:32 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5C6166A88B; Fri, 4 May 2018 14:39:32 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 5750A1031B; Fri, 4 May 2018 14:39:32 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w44EdWxh045250; Fri, 4 May 2018 14:39:32 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w44EdWho045249; Fri, 4 May 2018 14:39:32 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201805041439.w44EdWho045249@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Fri, 4 May 2018 14:39:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r333251 - head/usr.bin/time X-SVN-Group: head X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: head/usr.bin/time X-SVN-Commit-Revision: 333251 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 May 2018 14:39:32 -0000 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");