start-stop daemon

Michael A. Peters mpeters at mac.com
Mon Apr 21 16:28:35 PDT 2003


OK- I'll look at what pidof I was using next time I boot into LFS (since
I rebuilt everything via rpm once installed it's easy ;).
I will say that I was using the vanilla functions script from LFS when I
ran into this problem.

But at this point - I've completely ripped getpids(), loadproc(),
killproc(), reloadproc() from my functions script - and I'm using the
debian start-stop-daemon for starting/stopping/SIGHUP'n daemons.

I rewrote the statusproc() function to look at the PID of the full path
to the daemon (using which) and look at the PID in the PID file and make
its report accordingly, my rewrite of it does use the pidof but
obviously not the getpids() function that I ripped.

So all my boot scripts are now behaving the way they should. I find it
interesting that the original functions script gave me issues - I'll
look into it further.

My getpids() function certainly DID include the flags that are suppose
to avoid my problem:

getpids()
{
        base=${1##*/}
        pidlist=$(pidof -o $$ -o $PPID -x $base)
}

so if pidof isn't suppose to act the way it did with me, I'm curious as
to where the problem is in my system. If it matters I'm using
glibc-2.3.2 and hjl binutils. I don't think that should affect it, but
...


On Mon, 2003-04-21 at 10:42, Gerard Beekmans wrote:
> On April 20, 2003 04:33 am, Michael A. Peters wrote:
> > I'm curious as to the reason it no longer does.
> 
> One less package to use. pidof is installed in most cases anyways and it can 
> be told to work properly, read on...
> 
> > reinstall it) and then you try to manually restart it. The problem is
> > that getpids() sees the init script itself and reports that it is
> > already running.
> 
> In the LFS bootscripts, pidof is run like this:
> 	pidof -o $$ -o $$PID
> 
> The -o options ignore certain PID's. As you may be aware $$ is the PID of the 
> process itself (the bash shell in which the init.d/functions script runs in 
> this case) and $PPID ignores the parent PID of the functions script, which is 
> init.d/scriptname (init.d/sshd init.d/myservice, and so on).
> 
> Allow me to back this up with some proof. Plain vanilla LFS bootscripts:
> 
> SSHD is not running:
> 
> 	root at lorien/etc/rc.d/init.d# ps ax|grep ssh
> 	root at lorien/etc/rc.d/init.d# 
> 
> Now trying to start it:
> 
> 	root at lorien/etc/rc.d/init.d# ./sshd start
> 	Starting SSHD...                                                     [  OK  ]
> 
> And let's try again:
> 
> 	root at lorien/etc/rc.d/init.d# ./sshd start
> 	Starting SSHD...                                 Already running     [ ATTN ]
> 
> 
> I'm editing the "getpids()" function in the "functions" script. Originally it 
> contained:
> 	pidlist=$(pidof -o $$ -o $PPID -x $base)
> 
> After editing:
> 	pidlist=$(pidof -x $base)
> 
> SSHD is not running:
> 
> 	root at lorien/etc/rc.d/init.d# ps ax|grep ssh
> 	root at lorien/etc/rc.d/init.d# 
> 
> Trying to start it:
> 
> 	root at lorien/etc/rc.d/init.d# ./sshd start 
> 	Starting SSHD...                                 Already running     [ ATTN ]
> 
> So as you can see, when the "-o $$" and "-o $PPID" options aren't used, pidof 
> will include the PID of the calling script itself and tell you it's already 
> running. When those two -o options are used, the calling script and its 
> parent are ignored, so it will only look at the remaining PIDs you want it to 
> look at.
> 
> Is it possible you aren't used the pidof program from the sysvinit package? If 
> not, that might explain the problem you are having. Matthias did a lot of 
> research on the different pidof and init implementations. IIRC he arived at 
> the conclusion that sysvinit's pidof is better (and thus he includes 
> sysvinit's tools in this own simpleinit-msb package for that reason). There 
> are test cases by Matthias in the archives of this mailinglist, somewhere.
> 
> > I though that perhaps using the full path with loadproc() would solve
> > the issue. It doesn't. So - I'm curious as to what the reason is that
> 
> It doesn't. The functions script use 'basename' to strip this path. The full 
> path is not always preserved in /proc/<pid>/cmdline (I believe it's the 
> cmdline file at any rate, I can be wrong of course) so it's not very useful.
> 
> > the (imho better) debian start-stop daemon is no longer used. Especially
> > when the man page for pidof recommends against it use in init scripts.
> 
> The reason is that we honestly don't believe it's necessary.
> 
> -- 
> Gerard Beekmans
> www.linuxfromscratch.org
> 
> -*- If Linux doesn't have the solution, you have the wrong problem -*-
-- 
Michael A. Peters <mpeters at mac.com>

-- 
Unsubscribe: send email to listar at linuxfromscratch.org
and put 'unsubscribe lfs-dev' in the subject header of the message



More information about the lfs-dev mailing list