LFS-5.1-pre1 info

Nathan Coulson conathan at conet.dyndns.org
Fri Jan 30 13:35:44 PST 2004


> Matthew Burgess wrote:
>
>>lfs-bootscripts 0.12 - 0.13
>>lfs-utils 0.4.2 - 0.4.3 (untested, we trust Zack right :) )
>>
>>
> Then I add a wish to the list, concerning bootscripts:
>
> Some BLFS packages (currently only MySQL, but there will be also
> winbindd from SAMBA 3.0.x) require the process to be killed not by
> enumerating all pids as we do now, but by reading the pid from the pid
> file. Since there will be more than one package that needs this
> functionality, we want to put that as a function into
> /etc/rc.d/init.d/functions.
>
> And a side note. The "loadproc" and "killproc" as defined by LSB (get
> the pid from a file in /var/run) are IMHO not well designed. They cannot
> be implemented correctly at all if a program cannot put its pid file in
> /var/run due to insufficient permissions. Currently this includes MySQL,
> Apache, SQUID (they run from another user and /var/run is writable only
> by root) and BIND (it is chrooted and cannot access /var/run). So why
> follow this bad standard and not wait until it is corrected?
>
> --
> Alexander E. Patrakov

if I recall, mysql only has one PID which should have been killed.

I dont know how this will work, but does anyone think that adding

                if [ -f "$PIDFILE" ]; then
                        pidlist="`cat "$PIDFILE"` $pidlist";
                fi

to the killproc will help?  [it'll append contents of a PIDFILE to the
$pidlist], so that the first pid that gets killed first is the one we
wish.  and if for some reason, the pidfile got messed up, then it'll kill
the running pids anyway.

then change to the bottom

                if [ $failure = 0 ]; then
                        rm -f /var/run/$base.pid
                        if [ -f "$PIDFILE" ]; then rm -f $PIDFILE; fi
                fi

[looks like I'll be doing some testing tonight]


Full Killproc Method [New]  (I think the ash compliant script changed a
few other things since 1.12).

killproc()
{
        if [ $# = 0 ]
        then
                echo "Usage: killproc {program} [signal]"
                exit 1
        fi

        if [ -z "$2" ]; then
                signal=TERM
                fallback=KILL
        else
                signal=${2##-}
                signal=${signal##SIG}
                fallback=""
        fi

        getpids $1

        if [ -n "$pidlist" ]; then
                failure=0

                local i=0

                if [ -f "$PIDFILE" ]; then pidlist="`cat "$PIDFILE"`
$pidlist"; fi


                for pid in $pidlist
                do
                        kill -$signal $pid 2>/dev/null

                        while [ $i -lt $KILLDELAY ]; do
                                kill -0 $pid 2>/dev/null || break
                                sleep 1
                                i=`expr $i + 1`
                        done

                        if [ -n "$fallback" ]; then kill -$fallback $pid
2>/dev/null; fi

                        kill -0 $pid 2>/dev/null && failure=1
                done

                base=${1##*/}
                if [ $failure = 0 ]; then
                        rm -f /var/run/$base.pid
                        if [ -f "$PIDFILE" ]; then rm -f $PIDFILE; fi
                fi

                (exit $failure)
                evaluate_retval
        else
                print_status warning not_running
        fi
}



More information about the lfs-dev mailing list