summaryrefslogtreecommitdiffstats
path: root/usr.bin/top
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>1999-01-09 20:25:02 +0000
committerobrien <obrien@FreeBSD.org>1999-01-09 20:25:02 +0000
commit5ef1fe5a746e1c0d94e728b671737d381e878511 (patch)
treea3ebc7a1920ec766658c787379ec3c7b26cbaeea /usr.bin/top
parent48d88654f8eeed779ba34dafaa48e1f50e96008e (diff)
downloadFreeBSD-src-5ef1fe5a746e1c0d94e728b671737d381e878511.zip
FreeBSD-src-5ef1fe5a746e1c0d94e728b671737d381e878511.tar.gz
uptime display more in style with original code
Diffstat (limited to 'usr.bin/top')
-rw-r--r--usr.bin/top/machine.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index 116399b..53cf5d9 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -19,10 +19,11 @@
* Steven Wallace <swallace@freebsd.org>
* Wolfram Schneider <wosch@FreeBSD.org>
*
- * $Id: machine.c,v 1.16 1998/11/25 09:45:28 dfr Exp $
+ * $Id: machine.c,v 1.17 1998/11/26 12:59:21 bde Exp $
*/
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/param.h>
@@ -343,6 +344,9 @@ struct system_info *si;
{
long total;
load_avg avenrun[3];
+ int mib[2];
+ struct timeval boottime;
+ size_t bt_size;
/* get the cp_time array */
(void) getkval(cp_time_offset, (int *)cp_time, sizeof(cp_time),
@@ -438,6 +442,20 @@ struct system_info *si;
} else {
si->last_pid = -1;
}
+
+ /*
+ * Print how long system has been up.
+ * (Found by looking getting "boottime" from the kernel)
+ */
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_BOOTTIME;
+ bt_size = sizeof(boottime);
+ if (sysctl(mib, 2, &boottime, &bt_size, NULL, 0) != -1 &&
+ boottime.tv_sec != 0) {
+ si->boottime = boottime;
+ } else {
+ si->boottime.tv_sec = -1;
+ }
}
static struct handle handle;
OpenPOWER on IntegriCloud