Revision: 41431
          http://brlcad.svn.sourceforge.net/brlcad/?rev=41431&view=rev
Author:   brlcad
Date:     2010-11-23 04:05:35 +0000 (Tue, 23 Nov 2010)

Log Message:
-----------
damn I'm good.  implement some scary mad shell scripting here in order to kill 
long-running conversions while still timing them and capturing their output.  
to make this happen, we can no longer just use a here document fed to the 
'while read' loop because the kill signals sent to the children processes jack 
it up good.  instead, temp override stdin with our object list so the loop 
continues unabated.  add in some timer cleanup for the instances when we finish 
the conversion long within the time limit and we have a done deal.

Modified Paths:
--------------
    brlcad/trunk/sh/conversion.sh

Modified: brlcad/trunk/sh/conversion.sh
===================================================================
--- brlcad/trunk/sh/conversion.sh       2010-11-23 02:35:43 UTC (rev 41430)
+++ brlcad/trunk/sh/conversion.sh       2010-11-23 04:05:35 UTC (rev 41431)
@@ -348,7 +348,16 @@
     cmd="$GED -c \"$work\" search ."
     objects=`eval $cmd 2>&1 | grep -v Using`
     $VERBOSE_ECHO "\$ $cmd"
+    $VERBOSE_ECHO "$objects"
 
+    # stash stdin on fd3 and set stdin to our object list.  this is
+    # necessary because if a kill timer is called, input being read on
+    # the while loop will be terminated early.
+    exec 3<&0
+    exec 0<<EOF
+$objects
+EOF
+
     while read object ; do
 
        obj="`basename \"$object\"`"
@@ -358,11 +367,17 @@
            continue
        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 &
+        spid=$!
+
        # convert NMG
        nmg=FAIL
        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
+        wait $spid >/dev/null 2>&1
        $VERBOSE_ECHO "$output"
        real_nmg="`echo \"$output\" | tail -n 4 | grep real | awk '{print $2}'`"
 
@@ -373,11 +388,17 @@
            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=$!
+
        # 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
+        wait $spid >/dev/null 2>&1
        $VERBOSE_ECHO "$output"
        real_bot="`echo \"$output\" | tail -n 4 | grep real | awk '{print $2}'`"
 
@@ -395,10 +416,11 @@
        $ECHO "%s\tnmg: %s %s\tbot %s %s\t%s:%s" $status $nmg $real_nmg $bot 
$real_bot "$file" "$object"
        count=`expr $count + 1`
 
-    done <<EOF
-$objects
-EOF
+    done
 
+    # restore stdin
+    exec 0<&3
+
     rm -f "$work"
     shift
 done


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

Reply via email to