Package: procps
Version: 1:3.2.8-2
Severity: normal

When given null string as its pid, kill behaves as if it were given 0,
thus being a trouble to people writing this:

1 #!/bin/sh
2 PID=`pidof non-running-program`
3 /bin/kill "$PID"
4 do some other work...

Line 3 terminates the shell process effectively, probably not expected
by users unfamiliar with this odd behave of /bin/kill.

A patch is attatched to correct this problem, making kill treat null
string the same as an ordinal non-numerals.

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 2.6.30-1-686 (SMP w/2 CPU cores)
Locale: LANG=zh_CN.UTF-8, LC_CTYPE=zh_CN.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages procps depends on:
ii  initscripts               2.87dsf-1      scripts for initializing
and shutt
ii  libc6                     2.9-25         GNU C Library: Shared libraries
ii  libncurses5               5.7+20090803-2 shared libraries for
terminal hand
ii  lsb-base                  3.2-22         Linux Standard Base 3.2
init scrip

Versions of packages procps recommends:
ii  psmisc                        22.8-1     utilities that use the proc
file s

procps suggests no packages.

-- no debconf information
diff -urN procps-3.2.8/skill.c procps-3.2.8.new/skill.c
--- procps-3.2.8/skill.c	2008-03-24 13:48:39.000000000 +0800
+++ procps-3.2.8.new/skill.c	2009-10-16 17:29:48.000000000 +0800
@@ -307,7 +307,7 @@
     long pid;
     char *endp;
     pid = strtol(argv[argc],&endp,10);
-    if(!*endp){
+    if(!*endp && (endp != argv[argc])){
       if(!kill((pid_t)pid,signo)) continue;
       // The UNIX standard contradicts itself. If at least one process
       // is matched for each PID (as if processes could share PID!) and

Reply via email to