Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Sep 2001 12:10:02 -0700 (PDT)
From:      "Crist J. Clark" <cristjc@earthlink.net>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/30680: uptime and w utilities lie about real uptime
Message-ID:  <200109201910.f8KJA2D66277@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/30680; it has been noted by GNATS.

From: "Crist J. Clark" <cristjc@earthlink.net>
To: David Malone <dwmalone@maths.tcd.ie>
Cc: FreeBSD-gnats-submit@freebsd.org,
	"Vladimir B.Grebenschikov" <vova@express.ru>
Subject: Re: bin/30680: uptime and w utilities lie about real uptime
Date: Thu, 20 Sep 2001 12:04:50 -0700

 On Thu, Sep 20, 2001 at 05:40:05AM -0700, David Malone wrote:
 > The following reply was made to PR bin/30680; it has been noted by GNATS.
 > 
 > From: David Malone <dwmalone@maths.tcd.ie>
 > To: "Vladimir B.Grebenschikov" <vova@express.ru>
 > Cc: FreeBSD-gnats-submit@freebsd.org, freebsd-hackers@freebsd.org
 > Subject: Re: bin/30680: uptime and w utilities lie about real uptime
 > Date: Thu, 20 Sep 2001 13:31:49 +0100
 > 
 >  On Thu, Sep 20, 2001 at 03:21:08PM +0400, Vladimir B.Grebenschikov wrote:
 >  > why utility increases uptime on 30 seconds ??
 >  > Is any real reasons for it ?
 >  
 >  It adds 30 because it wants to round the number of minutes to the
 >  nearest minute, instead of rounding down. Unfortunately this isn't
 >  a sensible thing to do if you are also going to display the number
 >  of seconds.
 
 The only time this is noticed is when the time is printed in
 seconds. This should fix it,
 
 Index: src/usr.bin/w/w.c
 ===================================================================
 RCS file: /export/ncvs/src/usr.bin/w/w.c,v
 retrieving revision 1.48
 diff -u -r1.48 w.c
 --- src/usr.bin/w/w.c   2001/07/26 19:20:13     1.48
 +++ src/usr.bin/w/w.c   2001/09/20 19:00:57
 @@ -452,13 +452,15 @@
         if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 &&
             boottime.tv_sec != 0) {
                 uptime = now - boottime.tv_sec;
 +               /* Round to nearest minute. */
                 uptime += 30;
                 days = uptime / 86400;
                 uptime %= 86400;
                 hrs = uptime / 3600;
                 uptime %= 3600;
                 mins = uptime / 60;
 -               secs = uptime % 60;
 +               /* Undo rounding to calculate uptime in seconds. */
 +               secs = (uptime - 30) % 60;
                 (void)printf(" up");
                 if (days > 0)
                         (void)printf(" %d day%s,", days, days > 1 ? "s" : "");
 
 I will commit the fix later unless someone has comments.
 -- 
 Crist J. Clark                           cjclark@alum.mit.edu

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200109201910.f8KJA2D66277>