pidof killall

Bernhard Fischer rep.nop at aon.at
Wed Oct 25 14:25:48 PDT 2006


On Wed, Oct 25, 2006 at 11:50:56AM -0700, Larry Brigman wrote:
>On 10/24/06, Bernhard Fischer <rep.nop at aon.at> wrote:
>>Larry,
>>
>>On Tue, Oct 24, 2006 at 03:31:33PM -0700, Larry Brigman wrote:
>>>On 10/24/06, Bernhard Fischer <rep.nop at aon.at> wrote:
>>>>On Tue, Oct 24, 2006 at 11:49:33AM -0700, Larry Brigman wrote:
>>>>>It seems that both of these applets don't always work correctly.
>>>>>In version 1.2.1 if
>>>>>you use the start-stop-daemon to run telnetd the pidof will find the
>>>>>pid of the program
>>>>>if you run telnetd from the command line the pidof and also killall
>>>>>won't find the program
>>>>>even though they show up in the ps command.
>>>>
>>>>You'd need to provide the actual commands you used where it didn't work
>>>>for you.
>>>>
>>>>s38:/tmp/busybox# ./telnetd
>>>>s38 login:
>>>>bernhard at s38:/tmp/busybox$ ./busybox pidof telnetd
>>>>11182
>>>>Login timed out after 60 seconds.
>>>>
>>>>and
>>>>
>>>>s38:/tmp/busybox# PATH=":$PATH" ./telnetd
>>>>s38 login:
>>>>bernhard at s38:/tmp/busybox$ ./busybox pidof telnetd
>>>>11414
>>># start-stop-daemon --start --pidfile /var/run/telnetd --exec
>>>/usr/sbin/telnetd
>>># pidof telnetd
>>>656
>>># killall telnetd
>>># pidof telnetd
>>
>>ok, that's fine. Now this one
>>>
>>># telnetd
>>># pidof telnetd
>>>
>>># ps | grep telnetd
>>> 668 root        356 S   telnetd
>>> 675 root        412 S   grep telnetd
>>># killall telnetd
>>>killall: telnetd: no process killed
>>># ps | grep telnetd
>>> 668 root        432 S   telnetd
>>> 696 root        140 R   grep telnetd
>>>#
>>
>>stick a printf into find_pid_by_name, like so, and run that one again.
>>What does it say?
>>
>>$ svn diff libbb/find_pid_by_name.c
>>Index: libbb/find_pid_by_name.c
>>===================================================================
>>--- libbb/find_pid_by_name.c    (revision 16432)
>>+++ libbb/find_pid_by_name.c    (working copy)
>>@@ -31,6 +31,7 @@
>>
>>        pidList = xmalloc(sizeof(long));
>>        while ((p = procps_scan(0)) != 0) {
>>+fprintf(stderr," cmd='%s'  [%s]\n", p->short_cmd, pidName);
>>                if (strncmp(p->short_cmd, pidName, COMM_LEN-1) == 0) {
>>                        pidList = xrealloc( pidList, sizeof(long) * (i+2));
>>                        pidList[i++] = p->pid;
>>
>>
># telnetd
># pidof
>
># pidof telnetd
>cmd='init'  [telnetd]
>cmd='ksoftirqd/0'  [telnetd]
>cmd='desched/0'  [telnetd]
>cmd='events/0'  [telnetd]
>cmd='khelper'  [telnetd]
>cmd='kthread'  [telnetd]
>cmd='kblockd/0'  [telnetd]
>cmd='khubd'  [telnetd]
>cmd='pdflush'  [telnetd]
>cmd='pdflush'  [telnetd]
>cmd='kswapd0'  [telnetd]
>cmd='aio/0'  [telnetd]
>cmd='xfslogd/0'  [telnetd]
>cmd='xfsdatad/0'  [telnetd]
>cmd='xfsbufd'  [telnetd]
>cmd='kseriod'  [telnetd]
>cmd='syslogd'  [telnetd]
>cmd='klogd'  [telnetd]
>cmd='inetd'  [telnetd]
>cmd='rms'  [telnetd]
>cmd='ems'  [telnetd]
>cmd='els'  [telnetd]
>cmd='dropbear'  [telnetd]
>cmd='getty'  [telnetd]
>cmd='getty'  [telnetd]
>cmd='getty'  [telnetd]
>cmd='getty'  [telnetd]
>cmd='dropbear'  [telnetd]
>cmd='sh'  [telnetd]
>cmd='getty'  [telnetd]
>cmd='busybox'  [telnetd]
>cmd='busybox'  [telnetd]
>
>#
What libc are you using? Is busybox dynamically linked or static?


More information about the busybox mailing list