svn commit: r334897 - head/usr.bin/top
Eitan Adler
eadler at FreeBSD.org
Sat Jun 9 21:40:25 UTC 2018
Author: eadler
Date: Sat Jun 9 21:40:24 2018
New Revision: 334897
URL: https://svnweb.freebsd.org/changeset/base/334897
Log:
top(1): Implement long options
This also documents some reserved or differing options from top's
original upstream.
Modified:
head/usr.bin/top/top.c
Modified: head/usr.bin/top/top.c
==============================================================================
--- head/usr.bin/top/top.c Sat Jun 9 21:09:24 2018 (r334896)
+++ head/usr.bin/top/top.c Sat Jun 9 21:40:24 2018 (r334897)
@@ -21,6 +21,7 @@
#include <time.h>
#include <errno.h>
+#include <getopt.h>
#include <jail.h>
#include <stdbool.h>
#include <stdio.h>
@@ -86,6 +87,33 @@ static void (*d_process)(int line, char *thisline) = i
static void reset_display(void);
+
+static const struct option longopts[] = {
+ { "cpu-display-mode", no_argument, NULL, 'C' }, /* differs from orignal */
+ /* D reserved */
+ { "thread", no_argument, NULL, 'H' },
+ { "idle-procs", no_argument, NULL, 'I' },
+ { "system-procs", no_argument, NULL, 'S' },
+ { "thread-id", no_argument, NULL, 'T' }, /* differs from orignal */
+ { "user", required_argument, NULL, 'U' },
+ { "all", no_argument, NULL, 'a' },
+ { "batch", no_argument, NULL, 'b' },
+ /* c reserved */
+ { "displays", required_argument, NULL, 'd' },
+ { "interactive", no_argument, NULL, 'i' },
+ { "jail-id", no_argument, NULL, 'j' },
+ { "display-mode", required_argument, NULL, 'm' },
+ /* n is identical to batch */
+ { "sort-order", required_argument, NULL, 'o' },
+ { "pid", required_argument, NULL, 'p' },
+ { "quick", no_argument, NULL, 'q' },
+ { "delay", required_argument, NULL, 's' },
+ { "threads", no_argument, NULL, 't' },
+ { "uids", no_argument, NULL, 'u' },
+ { "version", no_argument, NULL, 'v' },
+ { "system-idle-procs", no_argument, NULL, 'z' }
+};
+
static void
reset_uids(void)
{
@@ -328,7 +356,7 @@ _Static_assert(sizeof(command_chars) == CMD_toggletid
optind = 1;
}
- while ((i = getopt(ac, av, "CSIHPabijJ:nquvzs:d:U:m:o:p:Ttw")) != EOF)
+ while ((i = getopt_long(ac, av, "CSIHPabijJ:nquvzs:d:U:m:o:p:Ttw", longopts, NULL)) != EOF)
{
switch(i)
{
More information about the svn-src-head
mailing list