[lttng-dev] [PATCH 2/5] run-report: Restore SIGPIPE default handler in subprocess calls
Christian Babeux
christian.babeux at efficios.com
Tue Dec 18 16:31:15 EST 2012
Python override the SIGPIPE default handler because it prefers to check
every write and raise an IOError exception rather than taking SIGPIPE [1].
This behavior has the unfortunate side-effect of polluting stdout with
broken pipe messages on shell pipelines invocations (e.g. echo foo |
grep something | etc.) in shell scripts spawned via subprocess.Popen().
This commit fix the polluting of stdout by restoring the default SIGPIPE
handler on subprocess calls.
[1] - http://bugs.python.org/issue1652
Signed-off-by: Christian Babeux <christian.babeux at efficios.com>
---
tests/run-report.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/run-report.py b/tests/run-report.py
index ca6e6a3..6f559c9 100755
--- a/tests/run-report.py
+++ b/tests/run-report.py
@@ -7,7 +7,7 @@ import Queue
import time
import shlex
-from signal import signal, SIGTERM, SIGINT
+from signal import signal, SIGTERM, SIGINT, SIGPIPE, SIG_DFL
SESSIOND_BIN_NAME = "lttng-sessiond"
SESSIOND_BIN_PATH = "src/bin/lttng-sessiond/"
@@ -182,7 +182,7 @@ class TestWorker(threading.Thread):
env = os.environ
env['TEST_NO_SESSIOND'] = '1'
- test = subprocess.Popen([bin_path_name], env=env)
+ test = subprocess.Popen([bin_path_name], env=env, preexec_fn = lambda: signal(SIGPIPE, SIG_DFL))
test.wait()
# Send ret value to main thread
--
1.8.0.2
More information about the lttng-dev
mailing list