#! /usr/bin/perl
#Looks for and kills frozen grading processes.

@procs=`ps -u cs131xx`;		#gets all procs even from other shells or terminated connections
shift @procs;
foreach $ps (@procs) {
  foreach $type (qw {runtests java gprolog mzscheme python wget}, @ARGV) {#wraptest
    kill 9, $1 if ($ps =~ m:\s+(\d+)\s.*\b$type\b:);
  }
}
sleep 2;
foreach $ps (@procs) {
  kill 9, $1 if ($ps =~ m:\s+(\d+)\s.*\bsh\b:);	#sh often die when above killed
}

