Fix: utils.sh: handle SIGPIPE
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 16 May 2019 19:07:58 +0000 (15:07 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 5 Sep 2019 20:51:54 +0000 (16:51 -0400)
perl prove closes its child pipes before giving it a chance to execute
the signal trap handler. This means the child will not be able to
complete execution of the trap handler if that handler writes to stdout
or stderr.

Work-around this situation by redirecting stdin, stdout, and stderr
to /dev/null if a SIGPIPE is caught.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/utils/utils.sh

index 63f13aa24e8d31d0677c42dc8404937388a29741..5de6d26a896024e3c205cdd7cbe64f03a5284fcd 100644 (file)
@@ -68,9 +68,21 @@ function full_cleanup ()
        trap - SIGTERM && kill -- -$$
 }
 
+function null_pipes ()
+{
+       exec 0>/dev/null
+       exec 1>/dev/null
+       exec 2>/dev/null
+}
 
 trap full_cleanup SIGINT SIGTERM
 
+# perl prove closes its child pipes before giving it a chance to run its
+# signal trap handlers. Redirect pipes to /dev/null if SIGPIPE is caught
+# to allow those trap handlers to proceed.
+
+trap null_pipes SIGPIPE
+
 function print_ok ()
 {
        # Check if we are a terminal
This page took 0.025517 seconds and 4 git commands to generate.