fix endless loop in debug-shell with IO redirection

Submitted by Johannes Stezenbach on Oct. 30, 2012, 10:22 a.m.

Details

Message ID 20121030102225.GA8303@sig21.net
State Accepted
Commit 5c67476c7342
Headers show

Commit Message

Johannes Stezenbach Oct. 30, 2012, 10:22 a.m.
CT_DEBUG_INTERACTIVE is disabled when stdin, stdout or
stderr are redirected, but the check is only done at
the start of the build and doesn't catch when individual
build commands use redirection.  When stdin is redirected
it will cause the debug shell to exit immediately, causing
and endless loop.  Thus, save the stdin/our/err file handles
and restore them before invoking the debug shell.

Signed-off-by: Johannes Stezenbach <js@sig21.net>


--
For unsubscribe information see http://sourceware.org/lists.html#faq

Comments

Yann E. MORIN Oct. 31, 2012, 12:09 a.m.
Johannes, All,

Your patch:
    scripts/functions: fix endless loop in debug-shell with IO redirection

has been applied as: #5c67476c7342
    http://crosstool-ng.org/hg/crosstool-ng/rev/5c67476c7342

Thank you!

Regards,
Yann E. MORIN.



--
For unsubscribe information see http://sourceware.org/lists.html#faq

Patch hide | download patch | download mbox

diff -r 9f6e46b6dc42 scripts/functions
--- a/scripts/functions	Tue Oct 30 00:23:51 2012 +0100
+++ b/scripts/functions	Tue Oct 30 11:13:17 2012 +0100
@@ -46,7 +46,7 @@ 
             old_trap="$(trap -p ERR)"
             trap -- ERR
             (
-                exec >&6
+                exec >&6 2>&7 <&8
                 printf "\r         \n\nCurrent command"
                 if [ -n "${cur_cmd}" ]; then
                     printf ":\n  %s\n" "${cur_cmd}"
@@ -131,7 +131,8 @@ 
 
 # Log policy:
 #  - first of all, save stdout so we can see the live logs: fd #6
-exec 6>&1
+# (also save stdin and stderr for use by CT_DEBUG_INTERACTIVE)
+exec 6>&1 7>&2 8<&0
 #  - then point stdout to the log file
 tmp_log_file="${CT_TOP_DIR}/build.log"
 rm -f "${tmp_log_file}"