Revision: 41464
http://brlcad.svn.sourceforge.net/brlcad/?rev=41464&view=rev
Author: brlcad
Date: 2010-11-25 05:30:10 +0000 (Thu, 25 Nov 2010)
Log Message:
-----------
more process trickery so that we can abort the limit timer that kills facetize
and reports without the dreaded killed process 'Terminated' messages. this is
achieved by not invoking a subshell, redirecting stderr through a pipe, and
killing the sleep children in the same parent shell. not pretty but gets the
job done. couldn't figure out how to get double-subshell (via shell functions)
to work so these have to be in inlined.
Modified Paths:
--------------
brlcad/trunk/sh/conversion.sh
Modified: brlcad/trunk/sh/conversion.sh
===================================================================
--- brlcad/trunk/sh/conversion.sh 2010-11-25 02:07:28 UTC (rev 41463)
+++ brlcad/trunk/sh/conversion.sh 2010-11-25 05:30:10 UTC (rev 41464)
@@ -247,7 +247,7 @@
echo ""
echo "Available options:"
echo " GED=/path/to/geometry/editor (default mged)"
- echo " MAXTIME=#seconds (default 30)"
+ echo " MAXTIME=#seconds (default 300)"
echo ""
echo "BRL-CAD is a powerful cross-platform open source solid modeling
system."
echo "For more information about BRL-CAD, see http://brlcad.org"
@@ -285,7 +285,7 @@
fi
###
-# ensure variable is set to something #
+# ensure variable is set to something
###
set_if_unset ( ) {
set_if_unset_name="$1" ; shift
@@ -305,7 +305,7 @@
# approximate maximum time in seconds that a given conversion is allowed to
take
set_if_unset GED mged
-set_if_unset MAXTIME 30
+set_if_unset MAXTIME 300
# commands that this script expects, make sure we can find MGED
MGED="`which $GED`"
@@ -320,6 +320,39 @@
fi
+###
+# start a process clock
+###
+start_timer ( ) {
+ if test $# -ne 5 ; then
+ echo "INTERNAL ERROR: incorrect arugments to start_timer [$# != 5]"
+ exit
+ fi
+
+ sleep $MAXTIME && test "x`ps auxwww | grep "$3" | grep facetize | grep
"${4}.${1}" | awk '{print $2}'`" != "x" && $ECHO "\t$2 conversion time limit
exceeded: $5" && kill -9 `ps auxwww | grep "$3" | grep facetize | grep
"${4}.${1}" | awk '{print $2}'`
+}
+
+
+###
+# stop the clock by killing the sleep process
+###
+stop_timer ( ) {
+
+ if test $# -lt 1 ; then
+ return
+ fi
+
+ for ppid in $* ; do
+ for pid in `ps xj | grep $ppid | grep sleep | grep -v grep | awk
'{print $2}'` ; do
+ # must kill sleep children first or they can continue running
orphaned
+ kill $pid >/dev/null 2>&1
+ done
+ kill $ppid >/dev/null 2>&1
+ done
+ wait >/dev/null 2>&1
+}
+
+
################
# start output #
################
@@ -378,7 +411,7 @@
fi
# start the limit timer
- sleep $MAXTIME && test "x`ps auxwww | grep "$work" | grep facetize |
grep "${obj}.nmg" | awk '{print $2}'`" != "x" && $ECHO "\tNMG conversion time
limit exceeded: $file:$object" && kill -9 `ps auxwww | grep "$work" | grep
facetize | grep "${obj}.nmg" | awk '{print $2}'` >/dev/null 2>&1 &
+ { sleep $MAXTIME && test "x`ps auxwww | grep "$work" | grep facetize |
grep "${obj}.nmg" | awk '{print $2}'`" != "x" && $ECHO "\tNMG conversion time
limit exceeded: $file:$object" && kill -9 `ps auxwww | grep "$work" | grep
facetize | grep "${obj}.nmg" | awk '{print $2}'` 2>&4 & } 4>&2 2>/dev/null
spid=$!
# convert NMG
@@ -386,8 +419,16 @@
cmd="$GED -c "$work" facetize -n \"${obj}.nmg\" \"${obj}\""
$VERBOSE_ECHO "\$ $cmd"
output=`eval time $cmd 2>&1 | grep -v Using`
- test "x`ps auxwww | grep $spid | grep -v grep`" != "x" && kill $spid
>/dev/null 2>&1
- wait $spid >/dev/null 2>&1
+
+ for pid in `ps xj | grep $spid | grep sleep | grep -v grep | awk
'{print $2}'` ; do
+ # must kill sleep children first or they can continue running
orphaned
+ kill $pid >/dev/null 2>&1
+ wait $pid >/dev/null 2>&1
+ done
+ # must wait in order to suppress kill messages
+ kill -9 $spid >/dev/null 2>&1
+ wait $spid >/dev/null 2>&1
+
$VERBOSE_ECHO "$output"
real_nmg="`echo \"$output\" | tail -n 4 | grep real | awk '{print $2}'`"
@@ -397,18 +438,26 @@
nmg=pass
nmg_count=`expr $nmg_count + 1`
fi
-
+
# start the limit timer
- sleep $MAXTIME && test "x`ps auxwww | grep "$work" | grep facetize |
grep "${obj}.bot" | awk '{print $2}'`" != "x" && $ECHO "\tBoT conversion time
limit exceeded: $file:$object" && kill -9 `ps auxwww | grep "$work" | grep
facetize | grep "${obj}.bot" | awk '{print $2}'` >/dev/null 2>&1 &
- spid=$!
+ { sleep $MAXTIME && test "x`ps auxwww | grep "$work" | grep facetize |
grep "${obj}.bot" | awk '{print $2}'`" != "x" && $ECHO "\tBoT conversion time
limit exceeded: $file:$object" && kill -9 `ps auxwww | grep "$work" | grep
facetize | grep "${obj}.bot" | awk '{print $2}'` 2>&4 & } 4>&2 2>/dev/null
+ spid=$!
# convert BoT
bot=FAIL
cmd="$GED -c "$work" facetize \"${obj}.bot\" \"${obj}\""
$VERBOSE_ECHO "\$ $cmd"
output=`eval time $cmd 2>&1 | grep -v Using`
- test "x`ps auxwww | grep $spid | grep -v grep`" != "x" && kill $spid
>/dev/null 2>&1
- wait $spid >/dev/null 2>&1
+
+ for pid in `ps xj | grep $spid | grep sleep | grep -v grep | awk
'{print $2}'` ; do
+ # must kill sleep children first or they can continue running
orphaned
+ kill $pid >/dev/null 2>&1
+ wait $pid >/dev/null 2>&1
+ done
+ # must wait in order to suppress kill messages
+ kill -9 $spid >/dev/null 2>&1
+ wait $spid >/dev/null 2>&1
+
$VERBOSE_ECHO "$output"
real_bot="`echo \"$output\" | tail -n 4 | grep real | awk '{print $2}'`"
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits