[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFC: fix for daemon start on package install/upgrade out-of-runlevel



On Sat, Sep 09, 2000 at 08:32:24PM -0400, Adam McKenna wrote:
>On Sat, Sep 09, 2000 at 06:23:03PM -0400, Robert D. Hilliard wrote:
>> Adam McKenna <adam-debian@flounder.net> writes:
>> 
>> > 
>> > On Sat, Sep 09, 2000 at 04:03:50PM -0400, Robert D. Hilliard wrote:
>> > >      ps ax|grep <daemon-name>|grep -v grep works for me.
>> > 
>> > if [ "`pidof <daemon>`" ] ; then
>> > ...
>> > fi
>> 
>>      For some reason pidof doesn't work on the dictd daemon, so it may
>> not work on others as well.  See Bug#67021.
>
>adam@spotted:/usr/share/doc/dictd$ ps auxww | grep dict
>nobody   16216  0.2  0.6  1768  876 ?        S    20:26   0:00 dictd 1.4.9:
>0/0
>adam     16218  0.0  0.3  1112  412 pts/6    S    20:26   0:00 grep dict
>adam@spotted:/usr/share/doc/dictd$ pidof "dictd 1.4.9: 0/0"
>16216
>
>Looks like it's working fine to me.

As the numbers on the RHS change this is hardly a solution for
maintainer upgrade scripts.

The problem is that dictd stuffs the lot into argv[0] separated by
spaces.  I suspect that if it were to use \0 to delimit the words pidof
would work fine.

A workaround for dictd is to use -x which additionally checks the
basename against the value in parens from /proc/*/stat.

Both pidof and killall tend to work best when given a full pathname in
which case the dev/ino of each /proc/*/exe is compared to that of the
argument, avoiding the whole issue of whether or not the program has
manipulated argv.

This unfortunately doesn't work if you are trying to kill the previous
version of a daemon in the postinst of a package, as the binary will
have changed.

    # pidof dictd | xargs -r ps
    # pidof /usr/sbin/dictd | xargs -r ps
      PID TTY      STAT   TIME COMMAND
    14769 ?        S      0:00 dictd 1.4.9: 0/0
    # pidof -x dictd | xargs -r ps       
      PID TTY      STAT   TIME COMMAND
    14769 ?        S      0:00 dictd 1.4.9: 0/0

Regards,
-- 
Brendan O'Dea                                        bod@compusol.com.au
Compusol Pty. Limited                  (NSW, Australia)  +61 2 9810 3633


-- 
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: