Perhaps something like this could be used instead? This has not been
thoroughly tested, so consider it a blueprint :-)

Idea: Initially, signal only the parent process with the INT signal to
let it gracefully end all its child-processes and itself. If the parent
process does not terminate within some threshold of time, something is
hanging and we basically perform a killall -TERM on the remaining processes.

    pkill -INT -P 1 `basename $DAEMON`
    TIMEOUT=30
    while pgrep -P 1 `basename $DAEMON` >/dev/null && test "$TIMEOUT"
-gt "0"; do
        TIMEOUT=$((TIMEOUT-1))
        sleep 1;
    done
    if test "$TIMEOUT" -eq "0"; then
        pkill -TERM `basename $DAEMON`
    fi

Food for thought...



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

Reply via email to