chiark / gitweb /
stest: If one of our secnets dies, call the test a failure
[secnet.git] / stest / common.tcl
index 388320a8cf2f8805a454a00ce377baac4a914fd6..a58ca6fbd7048d244394bf179a84a65a83850e35 100644 (file)
@@ -161,8 +161,7 @@ proc netlink-readable {location site} {
     switch -exact $site {
        inside {
            puts OK
-           set ok 1; # what a bodge
-           return
+           finish 0
        }
        outside {
            error "inside rx'd!"
@@ -218,6 +217,21 @@ proc finish {estatus} {
     exit $estatus
 }
 
+proc reap {} {
+    global pidmap
+    #puts stderr REAPING
+    foreach pid [array names pidmap] {
+       set got [wait -nohang $pid]
+       if {![llength $got]} continue
+       set info $pidmap($pid)
+       unset pidmap($pid)
+       puts stderr "reaped $info: $got"
+       finish 1
+    }
+}
+
+signal -restart trap SIGCHLD { after idle reap }
+
 proc udp-proxy {} {
     global socktmp udpsock
     set u $socktmp/udp