~ salmonella-environment-setup (master) /scripts/linux/hunt-a.out.sh
Trap1#! /bin/sh23## signal-tests sometimes keeps an a.out file running eating CPU. This4## script detects when an a.out is hanging and kills it if necessary56logfile="$HOME/salmonella/watchdog.log"78aout_pid() {9 echo "`ps ax | grep '\./[a]\.out' | awk '{print $1}'`"10}111213# Here we check if the process coresponding to the a.out file is14# running. If it is running, we just sleep and check again after some15# time. If after the wating time it is still running, we just kill16# it.1718sleep_time=15m1920pid=`aout_pid`21if [ -z "$pid" ]; then22 exit 023fi24if grep -q salmonella /proc/$pid/environ; then25 echo "[`date`] a.out found running. Sleeping for $sleep_time." >> $logfile26 sleep $sleep_time27else28 exit 029fi3031pid=`aout_pid`32if [ -z "$pid" ]; then33 exit 034fi35if grep -q salmonella /proc/$pid/environ; then36 echo "[`date`] a.out still running after $sleep_time. Killing it." >> $logfile37 kill -9 "$pid"38fi