diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2010-04-23 09:26:14 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2010-04-23 09:26:14 +0000 |
commit | b02984af7af13b97dbe2cd1cc09fa53ccc123427 (patch) | |
tree | 68c63d06f095dca16a464ca3fa52a63208838a52 | |
parent | 01ec204355d36eca91bc225fce353798c62b02f7 (diff) |
show hostname in header line; ok lum@ phessler@
-rw-r--r-- | usr.bin/top/display.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c index 89b15a44d77..200de0b9a95 100644 --- a/usr.bin/top/display.c +++ b/usr.bin/top/display.c @@ -1,4 +1,4 @@ -/* $OpenBSD: display.c,v 1.39 2010/03/24 05:03:15 lum Exp $ */ +/* $OpenBSD: display.c,v 1.40 2010/04/23 09:26:13 otto Exp $ */ /* * Top users/processes display for Unix @@ -237,9 +237,14 @@ i_loadave(pid_t mpid, double *avenrun) void i_timeofday(time_t * tod) { + static char buf[30]; + + if (buf[0] == '\0') + gethostname(buf, sizeof(buf)); + if (screen_length > 1 || !smart_terminal) { if (smart_terminal) { - move(0, screen_width - 8); + move(0, screen_width - 8 - strlen(buf) - 1); } else { if (fputs(" ", stdout) == EOF) exit(1); @@ -251,7 +256,7 @@ i_timeofday(time_t * tod) addstrp(foo); } #endif - printwp("%-8.8s", &(ctime(tod)[11])); + printwp("%s %-8.8s", buf, &(ctime(tod)[11])); putn(); } } |