This code is from killproc:

If killproc is called ( for example: /etc/init.d/sysklogd: killproc /sbin/klogd )

and the pid file exists and the process in not running:

then the case statement receives a 1 exit status from from pidlist=`pidofproc "${1}"` ,pidlist contains "" and pidfile is unset

so in processing that return status in the cast statement never removes the stale pid file as ${pidfile} is never set.


   # Check for a valid program
    if [ ! -e "${program}" ]; then return 5; fi

    # Check for a valid signal
    check_signal "${signal}"
    if [ "${?}" -ne "0" ]; then return 2; fi

    # Get a list of pids
    if [ -z "${pidfile}" ]; then
        # determine the pid by discovery
        pidlist=`pidofproc "${1}"`
        retval="${?}"
    else
        # The PID file contains the needed PIDs
        # Note that by LSB requirement, the path must be given to pidofproc,         # however, it is not used by the current implementation or standard.
        pidlist=`pidofproc -p "${pidfile}" "${1}"`
        retval="${?}"
    fi

    # Return a value ONLY
    # It is the init script's (or distribution's functions) responsibilty
    # to log messages!
    case "${retval}" in

        0)
            # Program is running correctly
            # Do nothing here, let killproc continue.
            ;;

        1)
            # Program is not running, but an invalid pid file exists
            # Remove the pid file.
            rm -f "${pidfile}"

            # This is only a success if no signal was passed.
            if [ -n "${nosig}" ]; then
                return 0
            else
                return 7
            fi
            ;;


Suggest the following.....

        1)
            # Program is not running, but an invalid pid file exists
            # Remove the pid file

            progname=${program##*/}
            if [[ -e "/run/${progname}.pid" ]]; then

            pidfile="/run/${progname}.pid"

            rm -f "${pidfile}"

            fi

            # This is only a success if no signal was passed.
            if [ -n "${nosig}" ]; then
                return 0
            else
                return 7
            fi

Or

        1)
            # Program is not running, but an invalid pid file exists
            # Remove the pid file

            progname=${program##*/}
            if [[ -e "/run/${progname}.pid" ]]; then rm -f "/run/${progname}.pid"; fi

            # This is only a success if no signal was passed.
            if [ -n "${nosig}" ]; then
                return 0
            else
                return 7
            fi

--
http://lists.linuxfromscratch.org/listinfo/lfs-support
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Do not top post on this list.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

http://en.wikipedia.org/wiki/Posting_style

Reply via email to