lttng-dev.lists.lttng.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: joraj@efficios.com, jgalar@efficios.com
Cc: lttng-dev@lists.lttng.org
Subject: [PATCH lttng-tools 3/6] Fix: utils.sh: handle SIGPIPE
Date: Thu, 16 May 2019 15:07:58 -0400	[thread overview]
Message-ID: <20190516190801.16878-3-mathieu.desnoyers__44394.3920008437$1558033798$gmane$org@efficios.com> (raw)
In-Reply-To: <20190516190801.16878-1-mathieu.desnoyers@efficios.com>

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>
---
 tests/utils/utils.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh
index 8f6381eb..53964027 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
-- 
2.17.1

  parent reply	other threads:[~2019-05-16 19:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190516190801.16878-1-mathieu.desnoyers@efficios.com>
2019-05-16 19:07 ` [PATCH lttng-tools 2/6] Fix: tests: error handling in high throughput limits test (v2) Mathieu Desnoyers
2019-05-16 19:07 ` Mathieu Desnoyers [this message]
2019-05-16 19:07 ` [PATCH lttng-tools 4/6] Fix: test: utils.sh: exit from process on full_cleanup Mathieu Desnoyers
2019-05-16 19:08 ` [PATCH lttng-tools 5/6] Cleanup: test: don't stop relayd twice Mathieu Desnoyers
2019-05-16 19:08 ` [PATCH lttng-tools 6/6] tests: invoke full_cleanup from script trap handlers, use modprobe -r Mathieu Desnoyers
2019-09-05 20:54 ` [PATCH lttng-tools 1/6] Improve handling of test SIGTERM/SIGINT (v2) Jérémie Galarneau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='20190516190801.16878-3-mathieu.desnoyers__44394.3920008437$1558033798$gmane$org@efficios.com' \
    --to=mathieu.desnoyers@efficios.com \
    --cc=jgalar@efficios.com \
    --cc=joraj@efficios.com \
    --cc=lttng-dev@lists.lttng.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).