=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/top/top.c,v retrieving revision 1.105 retrieving revision 1.106 diff -c -r1.105 -r1.106 *** src/usr.bin/top/top.c 2020/08/23 21:11:55 1.105 --- src/usr.bin/top/top.c 2020/08/26 16:21:28 1.106 *************** *** 1,4 **** ! /* $OpenBSD: top.c,v 1.105 2020/08/23 21:11:55 kn Exp $ */ /* * Top users/processes display for Unix --- 1,4 ---- ! /* $OpenBSD: top.c,v 1.106 2020/08/26 16:21:28 kn Exp $ */ /* * Top users/processes display for Unix *************** *** 133,139 **** #define CMD_pagedown 26 #define CMD_pageup 27 #define CMD_grep2 28 ! #define CMD_rtable 29 static void usage(void) --- 133,140 ---- #define CMD_pagedown 26 #define CMD_pageup 27 #define CMD_grep2 28 ! #define CMD_rtableid 29 ! #define CMD_rtable 30 static void usage(void) *************** *** 141,147 **** extern char *__progname; fprintf(stderr, ! "usage: %s [-1bCHIinqSu] [-d count] [-g string] [-o [-]field] " "[-p pid] [-s time]\n\t[-T [-]rtable] [-U [-]user] [number]\n", __progname); } --- 142,148 ---- extern char *__progname; fprintf(stderr, ! "usage: %s [-1bCHIinqStu] [-d count] [-g string] [-o [-]field] " "[-p pid] [-s time]\n\t[-T [-]rtable] [-U [-]user] [number]\n", __progname); } *************** *** 241,247 **** char *endp; int i; ! while ((i = getopt(ac, av, "1SHICbinqus:d:p:U:o:g:T:")) != -1) { switch (i) { case '1': combine_cpus = 1; --- 242,248 ---- char *endp; int i; ! while ((i = getopt(ac, av, "1SHICbinqus:d:p:U:o:g:T:t")) != -1) { switch (i) { case '1': combine_cpus = 1; *************** *** 339,344 **** --- 340,349 ---- "%s: invalid routing table", optarg); break; + case 't': + ps.rtable = true; + break; + default: usage(); exit(1); *************** *** 370,376 **** int main(int argc, char *argv[]) { ! char *uname_field = "USERNAME", *header_text, *env_top; const char *(*get_userid)(uid_t, int) = user_from_uid; char **preset_argv = NULL, **av = argv; int preset_argc = 0, ac = argc, active_procs, i, ncpuonline_now; --- 375,383 ---- int main(int argc, char *argv[]) { ! char *header_text, *env_top; ! char *uname_field = "USERNAME", *thread_field = " TID"; ! char *wait_field = "WAIT ", *rtable_field = " RTABLE"; const char *(*get_userid)(uid_t, int) = user_from_uid; char **preset_argv = NULL, **av = argv; int preset_argc = 0, ac = argc, active_procs, i, ncpuonline_now; *************** *** 391,396 **** --- 398,404 ---- ps.uid = (uid_t)-1; ps.huid = (uid_t)-1; ps.pid = (pid_t)-1; + ps.rtable = false; ps.rtableid = -1; ps.hrtableid = -1; ps.command = NULL; *************** *** 573,579 **** i_message(); /* get the string to use for the process area header */ ! header_text = format_header(ps.threads ? NULL : uname_field); /* update the header area */ i_header(header_text); --- 581,589 ---- i_message(); /* get the string to use for the process area header */ ! header_text = format_header( ! ps.threads ? thread_field : uname_field, ! ps.rtable ? rtable_field : wait_field); /* update the header area */ i_header(header_text); *************** *** 613,619 **** char * s; s = format_next_process(processes, ! ps.threads ? NULL : get_userid, &pid); i_process(i, s, pid == hlpid); } } --- 623,630 ---- char * s; s = format_next_process(processes, ! ps.threads ? NULL : get_userid, ps.rtable, ! &pid); i_process(i, s, pid == hlpid); } } *************** *** 668,674 **** char ch, *iptr; int change, i; struct pollfd pfd[1]; ! static char command_chars[] = "\f qh?en#sdkriIuSopCHg+P109)(/T"; /* * assume valid command unless told --- 679,685 ---- char ch, *iptr; int change, i; struct pollfd pfd[1]; ! static char command_chars[] = "\f qh?en#sdkriIuSopCHg+P109)(/Tt"; /* * assume valid command unless told *************** *** 1035,1041 **** if (skip < 0) skip = 0; break; ! case CMD_rtable: new_message(MT_standout, "Routing table: "); if (readline(tempbuf, sizeof(tempbuf)) > 0) { --- 1046,1052 ---- if (skip < 0) skip = 0; break; ! case CMD_rtableid: new_message(MT_standout, "Routing table: "); if (readline(tempbuf, sizeof(tempbuf)) > 0) { *************** *** 1052,1057 **** --- 1063,1074 ---- putr(); } else clear_message(); + break; + case CMD_rtable: + ps.rtable = !ps.rtable; + new_message(MT_standout | MT_delayed, + " %sisplaying routing tables.", + ps.rtable ? "D" : "Not d"); break; default: new_message(MT_standout, " BAD CASE IN SWITCH!");