pgrep: Enable case-insensitive process matching
FreeBSD has case-insensitive matching of processes in pgrep and pkill, which can be super-useful. This patch uncomments and documents the code needed to make this work. Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
parent
1209e75903
commit
9742c74e7c
3
pgrep.1
3
pgrep.1
@ -76,6 +76,9 @@ own process group.
|
||||
Only match processes whose real group ID is listed. Either the numerical or
|
||||
symbolical value may be used.
|
||||
.TP
|
||||
\fB\-i\fR, \fB\-\-ignore\-case\fR
|
||||
Match processes case-insensitively.
|
||||
.TP
|
||||
\fB\-l\fR, \fB\-\-list\-name\fR
|
||||
List the process name as well as the process ID.
|
||||
.RB ( pgrep
|
||||
|
14
pgrep.c
14
pgrep.c
@ -118,6 +118,7 @@ static int __attribute__ ((__noreturn__)) usage(int opt)
|
||||
fputs(_(" -f, --full use full process name to match\n"), fp);
|
||||
fputs(_(" -g, --pgroup <PGID,...> match listed process group IDs\n"), fp);
|
||||
fputs(_(" -G, --group <GID,...> match real group IDs\n"), fp);
|
||||
fputs(_(" -i, --ignore-case match case insensitively\n"), fp);
|
||||
fputs(_(" -n, --newest select most recently started\n"), fp);
|
||||
fputs(_(" -o, --oldest select least recently started\n"), fp);
|
||||
fputs(_(" -P, --parent <PPID,...> match only child processes of the given parent\n"), fp);
|
||||
@ -694,6 +695,7 @@ static void parse_opts (int argc, char **argv)
|
||||
{"full", no_argument, NULL, 'f'},
|
||||
{"pgroup", required_argument, NULL, 'g'},
|
||||
{"group", required_argument, NULL, 'G'},
|
||||
{"ignore-case", no_argument, NULL, 'i'},
|
||||
{"newest", no_argument, NULL, 'n'},
|
||||
{"oldest", no_argument, NULL, 'o'},
|
||||
{"parent", required_argument, NULL, 'P'},
|
||||
@ -727,7 +729,7 @@ static void parse_opts (int argc, char **argv)
|
||||
strcat (opts, "lad:vw");
|
||||
}
|
||||
|
||||
strcat (opts, "LF:cfnoxP:g:s:u:U:G:t:?Vh");
|
||||
strcat (opts, "LF:cfinoxP:g:s:u:U:G:t:?Vh");
|
||||
|
||||
while ((opt = getopt_long (argc, argv, opts, longopts, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
@ -798,11 +800,11 @@ static void parse_opts (int argc, char **argv)
|
||||
usage ('?');
|
||||
++criteria_count;
|
||||
break;
|
||||
/* case 'i': / * FreeBSD: ignore case. OpenBSD: withdrawn. See -I. This sucks. * /
|
||||
* if (opt_case)
|
||||
* usage (opt);
|
||||
* opt_case = REG_ICASE;
|
||||
* break; */
|
||||
case 'i': /* FreeBSD: ignore case. OpenBSD: withdrawn. See -I. This sucks. */
|
||||
if (opt_case)
|
||||
usage (opt);
|
||||
opt_case = REG_ICASE;
|
||||
break;
|
||||
/* case 'j': / * FreeBSD: restricted to the given jail ID * /
|
||||
* break; */
|
||||
case 'l': /* Solaris: long output format (pgrep only) Should require -f for beyond argv[0] maybe? */
|
||||
|
Loading…
Reference in New Issue
Block a user