new foreign-OS research noted
This commit is contained in:
parent
1b35a3b9c8
commit
5b13bb93c7
60
pgrep.c
60
pgrep.c
@ -48,6 +48,7 @@ static int opt_newest = 0;
|
|||||||
static int opt_negate = 0;
|
static int opt_negate = 0;
|
||||||
static int opt_exact = 0;
|
static int opt_exact = 0;
|
||||||
static int opt_signal = SIGTERM;
|
static int opt_signal = SIGTERM;
|
||||||
|
static int opt_case = 0;
|
||||||
|
|
||||||
static const char *opt_delim = "\n";
|
static const char *opt_delim = "\n";
|
||||||
static union el *opt_pgrp = NULL;
|
static union el *opt_pgrp = NULL;
|
||||||
@ -335,7 +336,7 @@ do_regcomp (void)
|
|||||||
re = opt_pattern;
|
re = opt_pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
re_err = regcomp (preg, re, REG_EXTENDED | REG_NOSUB);
|
re_err = regcomp (preg, re, REG_EXTENDED | REG_NOSUB | opt_case);
|
||||||
if (re_err) {
|
if (re_err) {
|
||||||
regerror (re_err, preg, errbuf, sizeof(errbuf));
|
regerror (re_err, preg, errbuf, sizeof(errbuf));
|
||||||
fputs(errbuf,stderr);
|
fputs(errbuf,stderr);
|
||||||
@ -504,22 +505,38 @@ parse_opts (int argc, char **argv)
|
|||||||
|
|
||||||
while ((opt = getopt (argc, argv, opts)) != -1) {
|
while ((opt = getopt (argc, argv, opts)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'G':
|
// case 'F': // FreeBSD: the arg is a file containing a PID to match
|
||||||
|
// break;
|
||||||
|
case 'G': // Solaris: match rgid/rgroup
|
||||||
opt_rgid = split_list (optarg, conv_gid);
|
opt_rgid = split_list (optarg, conv_gid);
|
||||||
if (opt_rgid == NULL)
|
if (opt_rgid == NULL)
|
||||||
usage (opt);
|
usage (opt);
|
||||||
++criteria_count;
|
++criteria_count;
|
||||||
break;
|
break;
|
||||||
|
// case 'I': // FreeBSD: require confirmation before killing
|
||||||
|
// break;
|
||||||
|
// case 'J': // Solaris: match by project ID (name or number)
|
||||||
|
// break;
|
||||||
|
// case 'L': // FreeBSD: the pidfile (see -F) must be locked with flock()
|
||||||
|
// break;
|
||||||
// case 'L': // OpenBSD: print full args along w/ PID
|
// case 'L': // OpenBSD: print full args along w/ PID
|
||||||
// opt_printargs = 1;
|
// opt_printargs = 1;
|
||||||
// break;
|
// break;
|
||||||
case 'P':
|
// case 'M': // FreeBSD: specify core (OS crash dump) file
|
||||||
|
// break;
|
||||||
|
// case 'N': // FreeBSD: specify alternate namelist file (for us, System.map -- but we don't need it)
|
||||||
|
// break;
|
||||||
|
case 'P': // Solaris: match by PPID
|
||||||
opt_ppid = split_list (optarg, conv_num);
|
opt_ppid = split_list (optarg, conv_num);
|
||||||
if (opt_ppid == NULL)
|
if (opt_ppid == NULL)
|
||||||
usage (opt);
|
usage (opt);
|
||||||
++criteria_count;
|
++criteria_count;
|
||||||
break;
|
break;
|
||||||
case 'U':
|
// case 'S': // FreeBSD: don't ignore the built-in kernel tasks
|
||||||
|
// break;
|
||||||
|
// case 'T': // Solaris: match by "task ID" (probably not a Linux task)
|
||||||
|
// break;
|
||||||
|
case 'U': // Solaris: match by ruid/rgroup
|
||||||
opt_ruid = split_list (optarg, conv_uid);
|
opt_ruid = split_list (optarg, conv_uid);
|
||||||
if (opt_ruid == NULL)
|
if (opt_ruid == NULL)
|
||||||
usage (opt);
|
usage (opt);
|
||||||
@ -528,63 +545,70 @@ parse_opts (int argc, char **argv)
|
|||||||
case 'V':
|
case 'V':
|
||||||
fprintf(stdout, "%s (%s)\n", progname, procps_version);
|
fprintf(stdout, "%s (%s)\n", progname, procps_version);
|
||||||
exit(0);
|
exit(0);
|
||||||
case 'd':
|
// case 'c': // Solaris: match by contract ID
|
||||||
|
// break;
|
||||||
|
case 'd': // Solaris: change the delimiter
|
||||||
opt_delim = strdup (optarg);
|
opt_delim = strdup (optarg);
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f': // Solaris: match full process name (as in "ps -f")
|
||||||
opt_full = 1;
|
opt_full = 1;
|
||||||
break;
|
break;
|
||||||
case 'g':
|
case 'g': // Solaris: match pgrp
|
||||||
opt_pgrp = split_list (optarg, conv_pgrp);
|
opt_pgrp = split_list (optarg, conv_pgrp);
|
||||||
if (opt_pgrp == NULL)
|
if (opt_pgrp == NULL)
|
||||||
usage (opt);
|
usage (opt);
|
||||||
break;
|
break;
|
||||||
// case 'i':
|
// case 'i': // FreeBSD: ignore case. OpenBSD: withdrawn. See -I. This sucks.
|
||||||
// opt_insensitive = 1;
|
// if (opt_case)
|
||||||
|
// usage (opt);
|
||||||
|
// opt_case = REG_ICASE;
|
||||||
// break;
|
// break;
|
||||||
case 'l':
|
// case 'j': // FreeBSD: restricted to the given jail ID
|
||||||
|
// break;
|
||||||
|
case 'l': // Solaris: long output format (pgrep only)
|
||||||
opt_long = 1;
|
opt_long = 1;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n': // Solaris: match only the newest
|
||||||
if (opt_oldest|opt_negate|opt_newest)
|
if (opt_oldest|opt_negate|opt_newest)
|
||||||
usage (opt);
|
usage (opt);
|
||||||
opt_newest = 1;
|
opt_newest = 1;
|
||||||
++criteria_count;
|
++criteria_count;
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o': // Solaris: match only the oldest
|
||||||
if (opt_oldest|opt_negate|opt_newest)
|
if (opt_oldest|opt_negate|opt_newest)
|
||||||
usage (opt);
|
usage (opt);
|
||||||
opt_oldest = 1;
|
opt_oldest = 1;
|
||||||
++criteria_count;
|
++criteria_count;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's': // Solaris: match by session ID -- zero means self
|
||||||
opt_sid = split_list (optarg, conv_sid);
|
opt_sid = split_list (optarg, conv_sid);
|
||||||
if (opt_sid == NULL)
|
if (opt_sid == NULL)
|
||||||
usage (opt);
|
usage (opt);
|
||||||
++criteria_count;
|
++criteria_count;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't': // Solaris: match by tty
|
||||||
opt_term = split_list (optarg, conv_str);
|
opt_term = split_list (optarg, conv_str);
|
||||||
if (opt_term == NULL)
|
if (opt_term == NULL)
|
||||||
usage (opt);
|
usage (opt);
|
||||||
++criteria_count;
|
++criteria_count;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u': // Solaris: match by euid/egroup
|
||||||
opt_euid = split_list (optarg, conv_uid);
|
opt_euid = split_list (optarg, conv_uid);
|
||||||
if (opt_euid == NULL)
|
if (opt_euid == NULL)
|
||||||
usage (opt);
|
usage (opt);
|
||||||
++criteria_count;
|
++criteria_count;
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v': // Solaris: as in grep, invert the matching (uh... applied after selection I think)
|
||||||
if (opt_oldest|opt_negate|opt_newest)
|
if (opt_oldest|opt_negate|opt_newest)
|
||||||
usage (opt);
|
usage (opt);
|
||||||
opt_negate = 1;
|
opt_negate = 1;
|
||||||
break;
|
break;
|
||||||
// Solaris -x, the standard, does ^(regexp)$
|
|
||||||
// OpenBSD -x, being broken, does a plain string
|
// OpenBSD -x, being broken, does a plain string
|
||||||
case 'x':
|
case 'x': // Solaris: use ^(regexp)$ in place of regexp (FreeBSD too)
|
||||||
opt_exact = 1;
|
opt_exact = 1;
|
||||||
break;
|
break;
|
||||||
|
// case 'z': // Solaris: match by zone ID
|
||||||
|
// break;
|
||||||
case '?':
|
case '?':
|
||||||
usage (opt);
|
usage (opt);
|
||||||
break;
|
break;
|
||||||
|
@ -1340,7 +1340,6 @@ static const format_struct format_array[] = {
|
|||||||
{"label", "LABEL", pr_context, sr_nop, 31, 0, SGI, ET|LEFT},
|
{"label", "LABEL", pr_context, sr_nop, 31, 0, SGI, ET|LEFT},
|
||||||
{"lastcpu", "C", pr_psr, sr_nop, 3, 0, BSD, TO|RIGHT}, // DragonFly
|
{"lastcpu", "C", pr_psr, sr_nop, 3, 0, BSD, TO|RIGHT}, // DragonFly
|
||||||
{"lim", "LIM", pr_lim, sr_rss_rlim, 5, 0, BSD, AN|RIGHT},
|
{"lim", "LIM", pr_lim, sr_rss_rlim, 5, 0, BSD, AN|RIGHT},
|
||||||
{"lockname", "LOCK", pr_nop, sr_nop, 6, WCH, BSD, TO|WCHAN}, /* mutex (FreeBSD) */
|
|
||||||
{"login", "LOGNAME", pr_nop, sr_nop, 8, 0, BSD, AN|LEFT}, /*logname*/ /* double check */
|
{"login", "LOGNAME", pr_nop, sr_nop, 8, 0, BSD, AN|LEFT}, /*logname*/ /* double check */
|
||||||
{"logname", "LOGNAME", pr_nop, sr_nop, 8, 0, XXX, AN|LEFT}, /*login*/
|
{"logname", "LOGNAME", pr_nop, sr_nop, 8, 0, XXX, AN|LEFT}, /*login*/
|
||||||
{"longtname", "TTY", pr_tty8, sr_tty, 8, 0, DEC, PO|LEFT},
|
{"longtname", "TTY", pr_tty8, sr_tty, 8, 0, DEC, PO|LEFT},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user