[BusyBox 0004054]: busybox 1.9.1 killall command doesn't work
bugs at busybox.net
bugs at busybox.net
Mon Jul 14 01:17:04 UTC 2008
A NOTE has been added to this issue.
======================================================================
http://busybox.net/bugs/view.php?id=4054
======================================================================
Reported By: bwondu
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 4054
Category: Other
Reproducibility: always
Severity: minor
Priority: normal
Status: assigned
======================================================================
Date Submitted: 07-10-2008 15:41 PDT
Last Modified: 07-13-2008 18:17 PDT
======================================================================
Summary: busybox 1.9.1 killall command doesn't work
Description:
executing killall <processname> retrun killall: <processname>: no process
killed
I tried to do the same thing as in busybox 1.1.0 which is in
libbb/procps.c (read_to_buf() function) replace any character < ' ' in the
string read from /proc/%d/cmdline. In libbb/find_pid_by_name.c
(find_pid_by_name() function), I removed the call to bb_basename and did a
strstr instead of strcmp and it worked. But since there are other
dependencies to these functions, I want to make sure that this doesn't
break anything. If you have a better fix for it please let me know as
killall in Busybox 1.1.0 works perfectly fine. Thanks
======================================================================
----------------------------------------------------------------------
vda - 07-10-08 16:41
----------------------------------------------------------------------
Before trying to fix it, we need to understand how exactly it fails.
Does it happen with 1.11.0? For me it works:
# strace -o log killall top
# tail log
read(5, "32314 (mc) S 32312 32314 32312 3"..., 1023) = 244
close(5) = 0
open("/proc/32314/cmdline", O_RDONLY|O_LARGEFILE) = 5
read(5, "/usr/bin/mc\0-d\0", 1023) = 15
close(5) = 0
getdents64(3, /* 0 entries */, 1024) = 0
close(3) = 0
kill(707, SIGTERM) = 0
kill(14022, SIGTERM) = 0
_exit(0) = ?
Can you provide your example? Attach full strace log to this bug.
----------------------------------------------------------------------
bwondu - 07-10-08 21:00
----------------------------------------------------------------------
open("/proc/25936/cmdline", O_RDONLY|O_LARGEFILE) = 4
read(4, "./busybox\0killall\0top\0", 1023) = 22
close(4) = 0
getdents64(3, /* 0 entries */, 1024) = 0
close(3) = 0
brk(0x8aad000) = 0x8aad000
ioctl(2147483647, SNDCTL_TMR_TIMEBASE or TCGETS, 0xbfe39758) = -1 EBADF
(Bad file descriptor)
brk(0x8aae000) = 0x8aae000
write(2, "killall: top: no process killed\n", 32) = 32
_exit(1) = ?
----------------------------------------------------------------------
vda - 07-11-08 03:08
----------------------------------------------------------------------
This is not a full strace log. Instead of pasting "tail log" result, push
[Upload File] button on this web page and upload _entire_ strace log file.
Please also specify the name of process you are trying to kill - "killall
<WHICH_PROGRAM?>".
----------------------------------------------------------------------
bwondu - 07-11-08 03:37
----------------------------------------------------------------------
I have uploaded a full tracelog. Please refer to stracelog. I tried to
kill nonsenseprocess.sh
----------------------------------------------------------------------
vda - 07-11-08 03:59
----------------------------------------------------------------------
Here is it:
open("/proc/32635/stat", O_RDONLY|O_LARGEFILE) = 4
read(4, "32635 (nonsenseprocess) S 32604 "..., 1023) = 200
close(4) = 0
The _ONLY_ way to match scripts by name in Linux is to look at so called
comm field in /proc/$PID/stat.
Because /proc/$PID/cmdline will have "/bin/sh",NUL,"<scriptname>",NUL,...
and /proc/$PID/exe symlink will point to /bin/sh, and neither of these are
indicative that this process is named <scriptname>, right?
So we are left with /proc/$PID/stat's comm field - the
"...(<scriptname>)..." thing. But it is limited to 15 chars. If killall
sees comm field which is exactly 15 chars long, it does not use it because
it is truncated - in your example, it can be a truncated version of
"nonsenseprocess.sh" or truncated version of
"nonsenseprocess_which_you_dont_want_to_kill_at_all_costs"!
Killall should be able to kill scripts with names less than 15 chars.
----------------------------------------------------------------------
bwondu - 07-13-08 18:17
----------------------------------------------------------------------
Since we know how many bytes were read from the /proc/%d/cmd file, we can
change the null characters to non-null values (spaces). If you use that
file, there is no need to worry about truncation.
My 2 cents.
Issue History
Date Modified Username Field Change
======================================================================
07-10-08 15:41 bwondu New Issue
07-10-08 15:41 bwondu Status new => assigned
07-10-08 15:41 bwondu Assigned To => BusyBox
07-10-08 16:41 vda Note Added: 0009134
07-10-08 21:00 bwondu Note Added: 0009144
07-10-08 21:01 bwondu File Added: log
07-11-08 02:39 bwondu File Added: stracelog
07-11-08 03:08 vda Note Added: 0009154
07-11-08 03:37 bwondu Note Added: 0009164
07-11-08 03:59 vda Note Added: 0009174
07-13-08 18:17 bwondu Note Added: 0009234
======================================================================
More information about the busybox-cvs
mailing list