Starting service daemons
Denis Vlasenko
vda.linux at googlemail.com
Tue Mar 27 14:36:33 PDT 2007
On Tuesday 27 March 2007 13:28, hinko.kocevar at cetrtapot.si wrote:
> Natanael Copa wrote:
> > On Tue, 2007-03-27 at 09:16 +0200, hinko.kocevar at cetrtapot.si wrote:
> >> Hello,
> >>
> >
> > Use start-stop-daemon -n or with pidfiles.
> >
>
> Ok, thanx.
> I've tried -m -p /var/lock/pidfile and strange thing happens - actual
> PID number recoreded in the pidfile doesn't belong to the daemon being
> started. It belongs to the process that already finished. Eg.
>
> # start-stop-daemon --start -m -p /var/lock/crond.pid -x /sbin/crond --
> -c /etc/crontab/
>
> # ps
> ...
> 4274 root 192 S /sbin/crond -c /etc/crontab/
>
> # cat /var/lock/crond.pid
> 4272
start-stop-daemon --start -m -p z.pid -x /bin/sleep 100
Pidfile contains 12422
and in ps output I see:
12422 root /bin/sleep 100
You don't see it because you start _self-daemonizing_ applets -
they fork and then parent exits. Of course start-stop-daemon
records PID of parent process!
Which leads me to a question "why do you need start-stop-daemon
at all" if you can do the same in shell:
#!/bin/sh
echo $$ >z.pid; exec /bin/sleep 100
Simple, huh?
--
vda
More information about the busybox
mailing list