From 64249acad0332e3b28aa89adf3390778d8839295 Mon Sep 17 00:00:00 2001 From: Nir Cohen Date: Tue, 17 Jan 2017 21:03:07 +0200 Subject: [PATCH] Fix empty stdin results in a hung process --- backtrace.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backtrace.py b/backtrace.py index 6a114cb..7c4e9ae 100644 --- a/backtrace.py +++ b/backtrace.py @@ -222,12 +222,17 @@ def _extract_traceback(text): def _stdin_hook(args): - output = sys.stdin.readlines() + if not sys.stdin.isatty(): + output = sys.stdin.readlines() + else: + sys.exit( + 'No input provided. Make sure you pipe stderr into ' + 'backtrace.') if TRACEBACK_IDENTIFIER not in output: sys.exit( 'No Traceback detected. Make sure you pipe stderr to ' - 'backtrace correctly.') + 'backtrace.') tb, all_else = _extract_traceback(output) sys.stdout.write(''.join(all_else))