]> granicus.if.org Git - psmisc/commitdiff
killall max names fixed
authorCraig Small <csmall@users.sourceforge.net>
Sat, 16 Jun 2012 08:44:34 +0000 (18:44 +1000)
committerCraig Small <csmall@users.sourceforge.net>
Sat, 16 Jun 2012 08:44:34 +0000 (18:44 +1000)
The maximum number of names was not documented and was out by one.
Problem reported by J.A. Bezemer
Bug-Debian: http://bugs.debian.org/677428

ChangeLog
doc/killall.1
src/killall.c

index 0b7e4eb19317a0b2443a1cce42107d5e99b13c30..78ad3dba1eadb8c649b71f5498d87512b114f171 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ Changes in 22.18
        * Added AC_CANONICAL_TARGET for target_os Debian #673485
        * sed doesn't have [0-9]+ replace with [0-9][0-9]*
        * assert in killall triggered for small lifetimes Debian #628617
+       * killall MAX_NAMES off by one Debian #677428
 
 
 Changes in 22.17
index 817328f876fb7dd87fe0310b4c2e42c1a2b7efad..b94fb6a0f89c35366252ed3e7b607ffeb065da82 100644 (file)
@@ -1,4 +1,4 @@
-.TH KILLALL 1 2011-02-22 "Linux" "User Commands"
+.TH KILLALL 1 2012-06-16 "Linux" "User Commands"
 .SH NAME
 killall \- kill processes by name
 .SH SYNOPSIS
@@ -115,6 +115,11 @@ a new process with the same PID between scans.
 .PP
 If processes change their name, \fBkillall\fP may not be able to match 
 them correctly.
+.PP
+\fBkillall\fP has a limit of names that can be specified on the command line. 
+This figure is the size of an unsigned long multiplied by 8. For most 32
+bit systems the limit is 32 and similarly for a 64 bit system the limit is 
+usually 64.
 .SH AUTHORS
 Werner Almesberger <werner@almesberger.net> wrote the original version
 of psmisc. Since version 20 Craig Small <csmall@enc.com.au>
index c08d1421853cfe0e61b1cf8a97437a85add28e7a..6a6623cc15e3a8187c8a82ee486243d448c246ed 100644 (file)
@@ -81,6 +81,7 @@
 #define ER_OOFRA   -4
 
 #define NOT_PIDOF_OPTION if (pidof) usage(NULL)
+#define MYNAME ((pidof)?"pidof":"killall")
 
 static int verbose = 0, exact = 0, interactive = 0, reg = 0,
            quiet = 0, wait_until_dead = 0, process_group = 0,
@@ -130,7 +131,7 @@ uptime()
    char buf[2048];
    FILE* file;
    if (!(file=fopen( PROC_BASE "/uptime", "r"))) {
-      fprintf(stderr, "error opening uptime file\n");  
+      fprintf(stderr, "%s: error opening uptime file\n",MYNAME);       
       exit(1);
    }
    savelocale = setlocale(LC_NUMERIC, NULL);
@@ -206,7 +207,7 @@ match_process_uid(pid_t pid, uid_t uid)
        fclose(f);
        if (re==-1)
        {
-               fprintf(stderr, _("Cannot get UID from process status\n"));
+               fprintf(stderr, _("%s: Cannot get UID from process status\n"), MYNAME);
                exit(1);
        }
        return re;
@@ -232,7 +233,7 @@ build_regexp_list(int names, char **namelist)
        {
                if (regcomp(&reglist[i], namelist[i], flag) != 0) 
                {
-                       fprintf(stderr, _("Bad regular expression: %s\n"), namelist[i]);
+                       fprintf(stderr, _("%s: Bad regular expression: %s\n"), MYNAME, namelist[i]);
                        exit (1);
                }
        }
@@ -443,8 +444,8 @@ kill_all (int signal, int names, char **namelist, struct passwd *pwent)
          if (exact && !okay)
            {
              if (verbose)
-               fprintf (stderr, _("skipping partial match %s(%d)\n"), comm,
-                        pid_table[i]);
+               fprintf (stderr, _("%s: skipping partial match %s(%d)\n"),
+                       MYNAME, comm, pid_table[i]);
              continue;
            }
          got_long = okay;
@@ -544,8 +545,8 @@ kill_all (int signal, int names, char **namelist, struct passwd *pwent)
            pgids[i] = id;
            if (id < 0)
              {
-               fprintf (stderr, "getpgid(%d): %s\n", pid_table[i],
-                  strerror (errno));
+               fprintf (stderr, "%s: getpgid(%d): %s\n",
+                          MYNAME, pid_table[i], strerror (errno));
              }
            for (j = 0; j < i; j++)
              if (pgids[j] == id)
@@ -868,12 +869,14 @@ main (int argc, char **argv)
 #endif
     usage(NULL);
 
-  if (argc - myoptind > MAX_NAMES + 1) {
-    fprintf (stderr, _("Maximum number of names is %d\n"), MAX_NAMES);
+  if (argc - myoptind > MAX_NAMES) {
+    fprintf (stderr, _("%s: Maximum number of names is %d\n"),
+          MYNAME, MAX_NAMES);
     exit (1);
   }
   if (!have_proc_self_stat()) {
-    fprintf (stderr, _("%s lacks process entries (not mounted ?)\n"), PROC_BASE);
+    fprintf (stderr, _("%s: %s lacks process entries (not mounted ?)\n"),
+               MYNAME, PROC_BASE);
     exit (1);
   }
   argv = argv + myoptind;