From: Faiyaz Ahmed Date: Mon, 19 May 2008 19:26:11 +0000 (+0000) Subject: Attempts to write to vsys FIFO when file exists. If process is blocked, kill and... X-Git-Tag: pf2slice-1.0-2~2 X-Git-Url: http://git.onelab.eu/?p=pf2slice.git;a=commitdiff_plain;h=65c3dd32629bce961539da1e6eca5fd30adb3880 Attempts to write to vsys FIFO when file exists. If process is blocked, kill and try again. --- diff --git a/pf2slice-initscript b/pf2slice-initscript index 788e212..9ecede7 100644 --- a/pf2slice-initscript +++ b/pf2slice-initscript @@ -4,13 +4,44 @@ # description: planetflow slice initscript # -. /etc/rc.d/init.d/functions +#. /etc/rc.d/init.d/functions + +DELTA=10 # Time to sleep between polls +VSYSSCRIPT="/vsys/pfmount.in" +VSYSCMD="pf" + +watchdog(){ + while [ 1 ]; do + # if the file exists, try writing to it. + if [ -a ${VSYSSCRIPT} ]; then + echo "Writing to Fifo" + /bin/echo ${VSYSCMD} > ${VSYSSCRIPT} & + PID=$! + # Wait for command to complete + sleep $DELTA + # check to see if PID is running + if kill -0 ${PID} >/dev/null 2>&1 ; then + # if PID is running, it's likely hung. Kill it. + echo "Blocked on Fifo. Killing" + kill ${PID} + else + # assume if PID is no longer, command completed + echo "Completed. Exitting" + exit 0 + fi + else + # no pipe yet. vsys probably hasn't started yet. wait. + echo "${VSYSSCRIPT} doesn't exist" + sleep $DELTA + fi + done +} + case "$1" in start) echo -n "starting the planetflow slice:" - echo "pf" > /vsys/pfmount.in - echo + watchdog 2> /dev/null ;; *) @@ -18,4 +49,6 @@ case "$1" in RETVAL=1 esac + + exit $RETVAL