[Swift-commit] r4260 - trunk/bin

wozniak at ci.uchicago.edu wozniak at ci.uchicago.edu
Mon Apr 4 12:54:49 CDT 2011


Author: wozniak
Date: 2011-04-04 12:54:49 -0500 (Mon, 04 Apr 2011)
New Revision: 4260

Modified:
   trunk/bin/swift
Log:
Allow swift to be killed


Modified: trunk/bin/swift
===================================================================
--- trunk/bin/swift	2011-04-04 15:42:32 UTC (rev 4259)
+++ trunk/bin/swift	2011-04-04 17:54:49 UTC (rev 4260)
@@ -147,6 +147,12 @@
     $BASH -c "echo $KEY $USERID $SCRIPTID $SCRIPTLENGTH -1 0 > /dev/udp/$LISTENER/$PORT" > /dev/null 2>&1 &
 fi
 
+trap_swift() {
+	sleep 1
+	SWIFT_JAVA_PID=$( ps --ppid $SWIFT_EVAL_PID | tail -n 1 | cut -d ' ' -f 1 )
+	kill $SWIFT_JAVA_PID
+}
+
 ### EXECUTE ############
 if test -n "$CYGWIN"; then
     set CLASSPATHSAVE=$CLASSPATH
@@ -154,7 +160,10 @@
     eval java ${OPTIONS} ${COG_OPTS} ${EXEC} ${CMDLINE}
     export CLASSPATH=$CLASSPATHSAVE
 else
-    eval java ${OPTIONS} ${COG_OPTS} -classpath ${LOCALCLASSPATH} ${EXEC} ${CMDLINE}
+	trap trap_swift SIGINT SIGTERM SIGQUIT
+    eval java ${OPTIONS} ${COG_OPTS} -classpath ${LOCALCLASSPATH} ${EXEC} ${CMDLINE} &
+	SWIFT_EVAL_PID=$!
+	wait
 fi
 return_code=$?
 




More information about the Swift-commit mailing list