From: Ian Jackson Date: Mon, 25 Nov 2019 00:01:34 +0000 (+0000) Subject: stest: If one of our secnets dies, call the test a failure X-Git-Tag: v0.6.0~229 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=secnet.git;a=commitdiff_plain;h=31c904ba594c34409eacde50020539c7290a460a stest: If one of our secnets dies, call the test a failure This involves use of TclX's `signal' facility. In my tests it was easy to make Tcl deadlock by doing too much work in the signal handler. In particular reaping children is a bad idea. Also signals are not blocked during the signal handler so it would have to be reentrant. Instead, use `after idle'. That is quite soon enough for the reap to run, and in my tests with TclX 8.4 it all works properly. Signed-off-by: Ian Jackson --- diff --git a/stest/common.tcl b/stest/common.tcl index d6250c3..a58ca6f 100644 --- a/stest/common.tcl +++ b/stest/common.tcl @@ -217,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