[jboss-cvs] JBossAS SVN: r88453 - projects/jboss-osgi/trunk/build/distribution/runtime/bin.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri May 8 12:00:02 EDT 2009


Author: thomas.diesler at jboss.com
Date: 2009-05-08 12:00:01 -0400 (Fri, 08 May 2009)
New Revision: 88453

Modified:
   projects/jboss-osgi/trunk/build/distribution/runtime/bin/run.sh
Log:
Improve runtime PID handling

Modified: projects/jboss-osgi/trunk/build/distribution/runtime/bin/run.sh
===================================================================
--- projects/jboss-osgi/trunk/build/distribution/runtime/bin/run.sh	2009-05-08 15:51:44 UTC (rev 88452)
+++ projects/jboss-osgi/trunk/build/distribution/runtime/bin/run.sh	2009-05-08 16:00:01 UTC (rev 88453)
@@ -142,7 +142,31 @@
 # Execute the JVM in the foreground
 "$JAVA" $JAVA_OPTS \
   -classpath "$OSGI_CLASSPATH" \
-  org.jboss.osgi.spi.framework.OSGiBootstrap "$@" &> /dev/null &
-  echo $! > $OSGI_HOME/bin/pid.txt
-  fg
-OSGI_STATUS=$?
+  org.jboss.osgi.spi.framework.OSGiBootstrap "$@" &
+
+OSGI_PID=$!
+echo $OSGI_PID > $OSGI_HOME/bin/pid.txt
+
+# Trap common signals and relay them to the jboss process
+trap "kill -HUP  $OSGI_PID" HUP
+trap "kill -TERM $OSGI_PID" INT
+trap "kill -QUIT $OSGI_PID" QUIT
+trap "kill -PIPE $OSGI_PID" PIPE
+trap "kill -TERM $OSGI_PID" TERM
+
+# Wait until the background process exits
+WAIT_STATUS=128
+while [ "$WAIT_STATUS" -ge 128 ]; do
+  wait $OSGI_PID 2>/dev/null
+  WAIT_STATUS=$?
+  if [ "${WAIT_STATUS}" -gt 128 ]; then
+    SIGNAL=`expr ${WAIT_STATUS} - 128`
+    SIGNAL_NAME=`kill -l ${SIGNAL}`
+    echo "*** OSGi Runtime process (${OSGI_PID}) received ${SIGNAL_NAME} signal ***" >&2
+  fi          
+done
+if [ "${WAIT_STATUS}" -lt 127 ]; then
+  OSGI_STATUS=$WAIT_STATUS
+else
+  OSGI_STATUS=0
+fi




More information about the jboss-cvs-commits mailing list