-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Package: thttpd
Version: 2.23beta1-4.2
Followup-For: Bug #390112
Tags: patch

Hello,

Please consider the included patch.

I think I have found a solution, which fixes this bug and makes the
script a little more efficient, since there is no more greping the
output of ps, and no extra PID-variable to assign. There is only one 
simple kill command of which the exit code is checked. IMO this is 
enough of checking, that needs to be done, because, if one tries to
send a signal to a not existing PID, then there will be a non zero 
exit code from the kill command.

So, when starting the thttpd, there will be send a SIGCONT, so that an
eventually stopped thttpd-process gets resumed or an already running
simply will ignore it. In both cases the exit code is 0. In all other
situations, whether /var/run/thttpd is missing or the PID ist not
existing because thttpd has died in the meantime, then a new thttpd
will be started.

Same applies to the 'stop' and 'force-stop' cases (note that i have
changed the signal of force-stop to 15, since it says TERMINATE in the
echo, and also I see no sense in pretending to do something special by
'force-stopping' and then do the same as 'stop').

And please also note a minor change to line 20:

- -test -x $DAEMON || exit 0
+test -x $DAEMON || exit 1

    I think there should also be a non zero exit code, if there is no
    daemon command to execute.

Regards

Marcus Blumhagen

- --- /etc/init.d/thttpd        2006-09-09 17:59:03.000000000 +0200
+++ /etc/init.d/thttpd.fixed    2006-10-06 21:06:38.000000000 +0200
@@ -16,53 +16,41 @@
 DAEMON=/usr/sbin/thttpd
 NAME=thttpd
 PIDFILE=/var/run/thttpd.pid
 
- -test -x $DAEMON || exit 0
+test -x $DAEMON || exit 1
 
 case "$1" in
     start)
         echo -n "Starting web server: "
         if [ -f $PIDFILE ]; then
- -            PID=`cat $PIDFILE`
- -            if ps ax | grep -q "^$PID"; then
- -                echo "$DAEMON already running."
- -            else
- -                rm -f $PIDFILE
- -                $DAEMON -C $CONFFILE -i $PIDFILE
- -                echo "$NAME. "
- -            fi
- -        else
- -            $DAEMON -C $CONFFILE -i $PIDFILE
- -            echo "$NAME. "
+           if kill -18 `cat $PIDFILE 2> /dev/null` &> /dev/null ; then
+               echo "$DAEMON already running."
+           fi
+       else
+           rm -f $PIDFILE
+           $DAEMON -C $CONFFILE -i $PIDFILE
+           echo "$NAME. "
         fi
         ;;
     stop)
         echo -n "Stopping web server: "
         if [ -f $PIDFILE ]; then
- -            PID=`cat $PIDFILE`
- -            if ps ax | grep -q "^$PID"; then
- -                kill -10 $PID
- -                echo "$NAME"
- -            else
- -                echo "No $DAEMON found running; none killed."
- -            fi
- -            rm -f $PIDFILE
+           if kill -10 `cat $PIDFILE 2> /dev/null` &> /dev/null; then
+               rm -f $PIDFILE
+               echo "$NAME"
+           fi
         else
- -            echo "No $DAEMON found running; none killed."
+           echo "No $DAEMON found running; none killed."
         fi
         ;;
     force-stop)
         echo -n "Terminating web server: "
         if [ -f $PIDFILE ]; then
- -            PID=`cat $PIDFILE`
- -            if ps ax | grep -q "^$PID"; then
- -                kill -10 $PID
- -                echo "$NAME"
- -            else
- -                echo "No $DAEMON found running; none killed."
- -            fi
- -            rm -f $PIDFILE
+           if kill -15 `cat $PIDFILE 2> /dev/null` &> /dev/null; then
+               rm -f $PIDFILE
+               echo "$NAME"
+           fi
         else
             echo "No $DAEMON found running; none killed."
         fi
         ;;


- -- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (150, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-k7-lsm
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)

Versions of packages thttpd depends on:
ii  libc6                        2.3.6.ds1-4 GNU C Library: Shared libraries
ii  logrotate                    3.7.1-3     Log rotation utility

thttpd recommends no packages.

- -- debconf-show failed
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFJsba1MkssNtIhgsRAkNdAJwP5/1E2wjIQqhyNbI4P5BhJ84LJwCffF8q
khIsDeuNudu5l5Ja23QpIE8=
=RY50
-----END PGP SIGNATURE-----


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to