diff options
author | Craig Small <csmall@users.sourceforge.net> | 2012-06-16 18:44:34 +1000 |
---|---|---|
committer | Craig Small <csmall@users.sourceforge.net> | 2012-06-16 18:44:34 +1000 |
commit | 1921ed8748aaf6a7df72b4fafcf7898a6681c6a1 (patch) | |
tree | e8e45474f5cde381ae7e32f348e754d39d931762 | |
parent | b2852b285f4011f6190e18cb88df1b91353a28ae (diff) |
killall max names fixed
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
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | doc/killall.1 | 7 | ||||
-rw-r--r-- | src/killall.c | 23 |
3 files changed, 20 insertions, 11 deletions
@@ -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 diff --git a/doc/killall.1 b/doc/killall.1 index 817328f..b94fb6a 100644 --- a/doc/killall.1 +++ b/doc/killall.1 @@ -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> diff --git a/src/killall.c b/src/killall.c index c08d142..6a6623c 100644 --- a/src/killall.c +++ b/src/killall.c @@ -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(®list[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; |