diff options
author | Miles Bader <miles@gnu.org> | 1996-03-23 06:52:37 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1996-03-23 06:52:37 +0000 |
commit | 74df62968161b52bec92c1df8b0f138764cbe8cc (patch) | |
tree | 8c1dd46d08d244e1854c1fb37bc54e456badf744 | |
parent | a786a62abe277650bf01c8abaea61f5e22c3a839 (diff) |
(uptime): Add a temporary hack to pretend to show uptime.
-rw-r--r-- | utils/w.c | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -316,7 +316,7 @@ read_utmp_procs (proc_stat_list_t procs, char *name) static void uptime (proc_stat_list_t procs) { - struct timeval uptime; + struct stat st; char uptime_rep[20], tod_rep[20]; struct host_load_info *load; unsigned nusers = 0; @@ -324,8 +324,15 @@ uptime (proc_stat_list_t procs) proc_stat_list_for_each (procs, maybe_add_user); - /* What do we do??? XXX */ - bzero (&uptime, sizeof (uptime)); + /* Until we get a better way of finding out how long the system's been + up... XXX */ + if (stat ("/var/run/uptime", &st) != 0) + strcpy (uptime_rep, "chuck"); + else + { + struct timeval uptime = { st.st_ctime, 0 }; + fmt_named_interval (&uptime, 0, uptime_rep, sizeof (uptime_rep)); + } strftime (tod_rep, sizeof (tod_rep), "%r", localtime (&now.tv_sec)); if (tod_rep[0] == '0') @@ -335,8 +342,6 @@ uptime (proc_stat_list_t procs) if (errno) error (0, errno, "ps_host_load_info"); - fmt_named_interval (&uptime, 0, uptime_rep, sizeof (uptime_rep)); - printf ("%s up %s, %u user%s, load averages: %.2f, %.2f, %.2f\n", tod_rep, uptime_rep, nusers, nusers == 1 ? "" : "s", (double)load->avenrun[0] / (double)LOAD_SCALE, |