~ salmonella-environment-setup (master) a8e067b2cf63d8075f01bd61611923d0ef14fa07


commit a8e067b2cf63d8075f01bd61611923d0ef14fa07
Author:     Mario Domenech Goulart <mario@ossystems.com.br>
AuthorDate: Thu Oct 10 14:46:54 2013 -0300
Commit:     Mario Domenech Goulart <mario@ossystems.com.br>
CommitDate: Thu Oct 10 14:46:54 2013 -0300

    Add salmonella/hunt-a.out.sh
    
    signal-tests sometimes keeps an a.out file running eating CPU.  This
    script detects when an a.out is hanging and kills it if necessary

diff --git a/hunt-a.out.sh b/hunt-a.out.sh
new file mode 100755
index 0000000..2abec79
--- /dev/null
+++ b/hunt-a.out.sh
@@ -0,0 +1,38 @@
+#! /bin/sh
+
+## signal-tests sometimes keeps an a.out file running eating CPU.  This
+## script detects when an a.out is hanging and kills it if necessary
+
+logfile="$HOME/salmonella/watchdog.log"
+
+aout_pid() {
+    echo "`ps ax | grep '\./[a]\.out' | awk '{print $1}'`"
+}
+
+
+# Here we check if the process coresponding to the a.out file is
+# running.  If it is running, we just sleep and check again after some
+# time.  If after the wating time it is still running, we just kill
+# it.
+
+sleep_time=15m
+
+pid=`aout_pid`
+if [ -z "$pid" ]; then
+    exit 0
+fi
+if grep -q salmonella /proc/$pid/environ; then
+    echo "[`date`] a.out found running.  Sleeping for $sleep_time." >> $logfile
+    sleep $sleep_time
+else
+    exit 0
+fi
+
+pid=`aout_pid`
+if [ -z "$pid" ]; then
+    exit 0
+fi
+if grep -q salmonella /proc/$pid/environ; then
+    echo "[`date`] a.out still running after $sleep_time.  Killing it." >> $logfile
+    kill -9 "$pid"
+fi
Trap