Bug 625

Summary: procps_scan() incorrect behaviour
Product: Busybox Reporter: Leonid <lly.dev>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: major CC: busybox-cvs
Priority: P1    
Version: 1.15.x   
Target Milestone: ---   
Hardware: Other   
OS: Linux   
Host: Target: linux-mips
Build: 1.15.1
Attachments: This patch solves problem for me

Description Leonid 2009-09-22 18:27:11 UTC
Created attachment 667 [details]
This patch solves problem for me

In case of call procps_scan() function with mask PSSCAN_PID|PSSCAN_COMM|PSSCAN_ARGVN|PSSCAN_EXE as in find_pid_by_name() and some process has empty /proc/<pid>/cmdline (kernel daemon for example), it leaves previous results for sp->exe!
As result, find_pid_by_name() used in killall applet can give us wrong additional pids!

Sample part of real ps output:
...
   68 nobody     800 S    dnsmasq
   69 admin        0 SW   [khubd]
   83 admin      964 S    l2tpd
...

killall -1 dnsmasq tries to send SIGHUP to both 68 & 69 pids !

Patch attached, solves problem for me.
Comment 1 Denys Vlasenko 2009-09-22 21:03:17 UTC
Reproduced.

Try this patch:

http://busybox.net/downloads/fixes-1.15.1/busybox-1.15.1-pidof_killall.patch
Comment 2 Leonid 2009-09-23 15:57:59 UTC
Your variant of fix works well too, thanks.