Re: Bug#426877: Clarify what "sensible behaviour" is for init scripts
> Note that /etc/init.d/skeleton, on which many init scripts in Debian are
> based, handles this case correctly without using --oknodo.
Are you sure? These are the "start" and "stop" sections of skeleton
file in a Debian Etch:
-------------
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec
$DAEMON --test > /dev/null \
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
$DAEMON_ARGS \
|| return 2
# Add code here, if necessary, that waits for the process to be ready
# to handle requests from services started subsequently which depend
# on this one. As a last resort, sleep for some time.
}
#
# Function that stops the daemon/service
#
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5
--pidfile $PIDFILE --name $NAME
RETVAL="$?"
[ "$RETVAL" = 2 ] && return 2
# Wait for children to finish too if this is a daemon that forks
# and if the daemon is only ever run from this initscript.
# If the above conditions are not satisfied then add some other code
# that waits for the process to drop all resources that could be
# needed by services started subsequently. A last resort is to
# sleep for some time.
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5
--exec $DAEMON
[ "$?" = 2 ] && return 2
# Many daemons don't delete their pidfiles when they exit.
rm -f $PIDFILE
return "$RETVAL"
}
-------------
This is not the LSB behaviour. Athe --oknodo is just present in the
second call to "start-stop-daemon" of the "stop" action (and no more),
and the text is very clear:
do_start()
{
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
do_stop()
{
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
2008/7/6, Russ Allbery <rra@debian.org>:
> "\"Iñaki" Baz Castillo" <ibc@aliax.net> writes:
>
>> Opssss, sorry, I meant that "lighttpd DOESN'T use LSB specs but Debian
>> specs".
>>
>> You say that "it's not a sensible behaviour to fail when asked to start
>> a service that is already running" but this is the default behaviour of
>> Debian init scripts (dince --oknodo is optional and of course not always
>> used).
>
> Note that /etc/init.d/skeleton, on which many init scripts in Debian are
> based, handles this case correctly without using --oknodo.
>
> --
> Russ Allbery (rra@debian.org) <http://www.eyrie.org/~eagle/>
>
--
Iñaki Baz Castillo
<ibc@aliax.net>
Reply to: