2008-12-16 16:00:18 +01:00
|
|
|
--- pgrep.1
|
2009-05-15 21:45:51 +02:00
|
|
|
+++ pgrep.1 2007-10-05 14:36:42.000000000 +0200
|
2008-12-16 16:00:18 +01:00
|
|
|
@@ -7,7 +7,7 @@
|
|
|
|
pgrep, pkill \- look up or signal processes based on name and other attributes
|
|
|
|
|
|
|
|
.SH SYNOPSIS
|
|
|
|
-pgrep [\-flvx] [\-d \fIdelimiter\fP] [\-n|\-o] [\-P \fIppid\fP,...] [\-g \fIpgrp\fP,...]
|
|
|
|
+pgrep [\-cflvx] [\-d \fIdelimiter\fP] [\-n|\-o] [\-P \fIppid\fP,...] [\-g \fIpgrp\fP,...]
|
|
|
|
.br
|
|
|
|
[\-s \fIsid\fP,...] [\-u \fIeuid\fP,...] [\-U \fIuid\fP,...] [\-G \fIgid\fP,...]
|
|
|
|
.br
|
2009-05-15 21:45:51 +02:00
|
|
|
@@ -38,6 +38,9 @@ to each process instead of listing them
|
2008-12-16 16:00:18 +01:00
|
|
|
|
|
|
|
.SH OPTIONS
|
|
|
|
.TP
|
|
|
|
+\-c
|
|
|
|
+Suppress normal output; instead print a count of matching processes.
|
|
|
|
+.TP
|
|
|
|
\-d \fIdelimiter\fP
|
|
|
|
Sets the string used to delimit each process ID in the output (by
|
|
|
|
default a newline). (\fBpgrep\fP only.)
|
|
|
|
--- pgrep.c
|
2009-05-15 21:45:51 +02:00
|
|
|
+++ pgrep.c 2009-05-11 12:38:44.945901308 +0200
|
|
|
|
@@ -54,6 +54,7 @@ static int opt_oldest = 0;
|
2008-12-16 16:00:18 +01:00
|
|
|
static int opt_newest = 0;
|
|
|
|
static int opt_negate = 0;
|
|
|
|
static int opt_exact = 0;
|
|
|
|
+static int opt_count = 0;
|
|
|
|
static int opt_signal = SIGTERM;
|
|
|
|
static int opt_lock = 0;
|
|
|
|
static int opt_case = 0;
|
2009-05-15 21:45:51 +02:00
|
|
|
@@ -564,7 +565,7 @@ static void parse_opts (int argc, char *
|
2008-12-16 16:00:18 +01:00
|
|
|
strcat (opts, "ld:");
|
|
|
|
}
|
|
|
|
|
|
|
|
- strcat (opts, "LF:fnovxP:g:s:u:U:G:t:?V");
|
|
|
|
+ strcat (opts, "LF:cfnovxP:g:s:u:U:G:t:?V");
|
|
|
|
|
|
|
|
while ((opt = getopt (argc, argv, opts)) != -1) {
|
|
|
|
switch (opt) {
|
2009-05-15 21:45:51 +02:00
|
|
|
@@ -612,6 +613,9 @@ static void parse_opts (int argc, char *
|
2008-12-16 16:00:18 +01:00
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
// case 'c': // Solaris: match by contract ID
|
|
|
|
// break;
|
2009-05-15 21:45:51 +02:00
|
|
|
+ case 'c':
|
|
|
|
+ opt_count = 1;
|
|
|
|
+ break;
|
2008-12-16 16:00:18 +01:00
|
|
|
case 'd': // Solaris: change the delimiter
|
|
|
|
opt_delim = strdup (optarg);
|
|
|
|
break;
|
2009-05-15 21:45:51 +02:00
|
|
|
@@ -723,10 +727,14 @@ int main (int argc, char *argv[])
|
2008-12-16 16:00:18 +01:00
|
|
|
procs[i].num, strerror (errno));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
- if (opt_long)
|
|
|
|
- output_strlist(procs,num);
|
|
|
|
- else
|
|
|
|
- output_numlist(procs,num);
|
|
|
|
+ if (opt_count) {
|
|
|
|
+ fprintf(stdout, "%ld\n", num);
|
|
|
|
+ } else {
|
|
|
|
+ if (opt_long)
|
|
|
|
+ output_strlist (procs,num);
|
|
|
|
+ else
|
|
|
|
+ output_numlist (procs,num);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
return !num; // exit(EXIT_SUCCESS) if match, otherwise exit(EXIT_FAILURE)
|
|
|
|
}
|