summaryrefslogtreecommitdiffstats
path: root/contrib/top/top.c
diff options
context:
space:
mode:
authorstas <stas@FreeBSD.org>2007-04-14 10:16:52 +0000
committerstas <stas@FreeBSD.org>2007-04-14 10:16:52 +0000
commitb2e4c77a02a90972acaa19099d19be9f1dffa3a3 (patch)
tree27e5b3664f0b327277d5e828d295b654d2d94fb5 /contrib/top/top.c
parentfb6f6fd9a183da8573afa302e42cdf7684785a7d (diff)
downloadFreeBSD-src-b2e4c77a02a90972acaa19099d19be9f1dffa3a3.zip
FreeBSD-src-b2e4c77a02a90972acaa19099d19be9f1dffa3a3.tar.gz
- 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
Diffstat (limited to 'contrib/top/top.c')
-rw-r--r--contrib/top/top.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/contrib/top/top.c b/contrib/top/top.c
index 81933e4..970d143 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,
OpenPOWER on IntegriCloud