From: Mathieu Desnoyers Date: Thu, 16 May 2019 19:07:58 +0000 (-0400) Subject: Fix: utils.sh: handle SIGPIPE X-Git-Tag: v2.10.8~23 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ad7b9fd5ca4ce1016a1e4703b07a0fdd865e5178;p=lttng-tools.git Fix: utils.sh: handle SIGPIPE 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 Signed-off-by: Jérémie Galarneau --- diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh index 63f13aa24..5de6d26a8 100644 --- a/tests/utils/utils.sh +++ b/tests/utils/utils.sh @@ -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