diff options
author | Stanislav Sedov <stas@FreeBSD.org> | 2007-04-14 10:16:52 +0000 |
---|---|---|
committer | Stanislav Sedov <stas@FreeBSD.org> | 2007-04-14 10:16:52 +0000 |
commit | faac60c8fcc31dcc5cbd4bd575a00cea18c42d7d (patch) | |
tree | 27e5b3664f0b327277d5e828d295b654d2d94fb5 /contrib/top/top.c | |
parent | c105859eee3baab0b07645e4ec8de56ce06d97f5 (diff) | |
download | src-faac60c8fcc31dcc5cbd4bd575a00cea18c42d7d.tar.gz src-faac60c8fcc31dcc5cbd4bd575a00cea18c42d7d.zip |
- Add new 'a' switch and runtime option that allows 'top' to display process
titles extracted from argv vector instead of the real executable names.
This is useful when you want to watch applications that set their status
information via setproctitle(3).
Approved by: alfred
MFC after: 2 weeks
Notes
Notes:
svn path=/head/; revision=168710
Diffstat (limited to 'contrib/top/top.c')
-rw-r--r-- | contrib/top/top.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/contrib/top/top.c b/contrib/top/top.c index 81933e4454c6..970d143649da 100644 --- a/contrib/top/top.c +++ b/contrib/top/top.c @@ -65,6 +65,8 @@ extern char *optarg; /* imported from screen.c */ extern int overstrike; +static int fmt_flags = 0; + /* signal handling routines */ sigret_t leave(); sigret_t onalrm(); @@ -193,9 +195,9 @@ char *argv[]; fd_set readfds; #ifdef ORDER - static char command_chars[] = "\f qh?en#sdkriIutHmSCo"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCao"; #else - static char command_chars[] = "\f qh?en#sdkriIutHmSC"; + static char command_chars[] = "\f qh?en#sdkriIutHmSCa"; #endif /* these defines enumerate the "strchr"s of the commands in command_chars */ #define CMD_redraw 0 @@ -219,8 +221,9 @@ char *argv[]; #define CMD_viewtog 17 #define CMD_viewsys 18 #define CMD_wcputog 19 +#define CMD_showargs 20 #ifdef ORDER -#define CMD_order 20 +#define CMD_order 21 #endif /* set the buffer for stdout */ @@ -277,7 +280,7 @@ char *argv[]; optind = 1; } - while ((i = getopt(ac, av, "CSIHbinquvs:d:U:m:o:t")) != EOF) + while ((i = getopt(ac, av, "CSIHabinquvs:d:U:m:o:t")) != EOF) { switch(i) { @@ -316,6 +319,10 @@ char *argv[]; interactive = No; break; + case 'a': + fmt_flags ^= FMT_SHOWARGS; + break; + case 'd': /* number of displays to show */ if ((i = atoiwi(optarg)) == Invalid || i == 0) { @@ -651,7 +658,8 @@ restart: /* now show the top "n" processes. */ for (i = 0; i < active_procs; i++) { - (*d_process)(i, format_next_process(processes, get_userid)); + (*d_process)(i, format_next_process(processes, get_userid, + fmt_flags)); } } else @@ -1020,6 +1028,9 @@ restart: case CMD_viewsys: ps.system = !ps.system; break; + case CMD_showargs: + fmt_flags ^= FMT_SHOWARGS; + break; #ifdef ORDER case CMD_order: new_message(MT_standout, |