Your message dated Tue, 13 Jun 2006 11:29:36 +0200
with message-id <[EMAIL PROTECTED]>
and subject line add grep style -c option to pgrep
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: procps
Severity: wishlist

hi,

it might, in certain cases, be handy to have a grep like -c option in
order to be able to sum up the matched processes, like:

 [EMAIL PROTECTED]:~$ ./pgrep -c getty          
 6

diff for pgrep.c and pgrep.1 attached.

bye,
    - michael
--- procps-3.2.5/pgrep.1        2004-07-15 15:58:46.000000000 +0200
+++ procps-3.2.5.own/pgrep.1    2005-07-29 12:17:08.000000000 +0200
@@ -38,6 +38,9 @@
 
 .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.)
--- procps-3.2.5/pgrep.c        2004-10-19 19:53:47.000000000 +0200
+++ procps-3.2.5.own/pgrep.c    2005-07-29 12:39:26.000000000 +0200
@@ -47,6 +47,7 @@
 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 const char *opt_delim = "\n";
@@ -66,7 +67,7 @@
        if (i_am_pkill)
                fprintf (stderr, "Usage: pkill [-SIGNAL] [-fvx] ");
        else
-               fprintf (stderr, "Usage: pgrep [-flvx] [-d DELIM] ");
+               fprintf (stderr, "Usage: pgrep [-cflvx] [-d DELIM] ");
        fprintf (stderr, "[-n|-o] [-P PPIDLIST] [-g PGRPLIST] [-s SIDLIST]\n"
                 "\t[-u EUIDLIST] [-U UIDLIST] [-G GIDLIST] [-t TERMLIST] "
                 "[PATTERN]\n");
@@ -501,7 +502,7 @@
                strcat (opts, "ld:");
        }
                        
-       strcat (opts, "fnovxP:g:s:u:U:G:t:?V");
+       strcat (opts, "cfnovxP:g:s:u:U:G:t:?V");
        
        while ((opt = getopt (argc, argv, opts)) != -1) {
                switch (opt) {
@@ -581,6 +582,9 @@
                                usage (opt);
                        opt_negate = 1;
                        break;
+               case 'c':
+                       opt_count = 1;
+                       break;
                // Solaris -x, the standard, does ^(regexp)$
                // OpenBSD -x, being broken, does a plain string
                case 'x':
@@ -617,13 +621,17 @@
                        if (kill (procs[i].num, opt_signal) != -1) continue;
                        if (errno==ESRCH) continue; // gone now, which is OK
                        fprintf (stderr, "pkill: %ld - %s\n",
-                                procs[i].num, strerror (errno));
+                               procs[i].num, strerror (errno));
                }
        } else {
-               if (opt_long)
-                       output_strlist (procs);
-               else
-                       output_numlist (procs);
+               if (opt_count) {
+                       fprintf(stdout, "%d\n", procs[0].num);
+               } else {
+                       if (opt_long)
+                               output_strlist (procs);
+                       else
+                               output_numlist (procs);
+               }
        }
        return ((procs[0].num) == 0 ? 1 : 0);
 }

--- End Message ---
--- Begin Message ---
hi,

seems like this feature has been added at some point in the past, even i
cant find any entry either in the upstream or debian changelog
reagarding it.  Nevertheless, im closing this bugreport.

bye,
    - michael

--- End Message ---

Reply via email to