Re: [squid-users] squidctl script update

From: Colin Campbell <sgcccdc@dont-contact.us>
Date: Tue, 5 Jun 2001 08:51:19 +1000 (EST)

Hi,

On Mon, 4 Jun 2001, Andrei B. wrote:

>
> Here's a small update to the squidctl script I submitted soemtime ago,
> with a small fix.
>
> Problem :
>
> - when system crashed and a stale PID still existed, squid was not
> started with the erroneous assumption that it is still running.
>
> I don't know why, the test
> if [ "x$PID" != "x" ] && kill -0 $PID ; then ....
> failed to properly detect the stale PID.

What makes you think the pid was stale? It could have been in use by
another process, just not squid. Doing tests like this aren't sufficient
to ensure the process is dead. You really have to do something like:

PID=`cat pidfile`
if [ "x$PID" != "x" ]; then # pid exists
    if kill -0 $PID; then # a process using pid
        if ps -p $PID -o args|grep squid > /dev/null 2>&1; then
            echo squid ALREADY running
        else
            echo squid NOT running
        fi
    else # nothing using pid
        echo squid NOT running
    fi
else # no pid in file or no file
    echo squid NOT running
fi

Colin

Received on Mon Jun 04 2001 - 16:53:06 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 17:00:28 MST