scripts/functions: fix endless loop in debug-shell with IO redirection
authorJohannes Stezenbach <js@sig21.net>
Tue Oct 30 00:22:25 2012 +0000 (2012-10-30)
changeset 30975c67476c7342
parent 3096 d1766c2273d1
child 3098 ce5e3dd95fe3
scripts/functions: fix endless loop in debug-shell with IO redirection

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>
Message-Id: <20121030102225.GA8303@sig21.net>
Patchwork-Id: 195409
scripts/functions
     1.1 --- a/scripts/functions	Tue Oct 30 00:36:20 2012 +0000
     1.2 +++ b/scripts/functions	Tue Oct 30 00:22:25 2012 +0000
     1.3 @@ -46,7 +46,7 @@
     1.4              old_trap="$(trap -p ERR)"
     1.5              trap -- ERR
     1.6              (
     1.7 -                exec >&6
     1.8 +                exec >&6 2>&7 <&8
     1.9                  printf "\r         \n\nCurrent command"
    1.10                  if [ -n "${cur_cmd}" ]; then
    1.11                      printf ":\n  %s\n" "${cur_cmd}"
    1.12 @@ -131,7 +131,8 @@
    1.13  
    1.14  # Log policy:
    1.15  #  - first of all, save stdout so we can see the live logs: fd #6
    1.16 -exec 6>&1
    1.17 +# (also save stdin and stderr for use by CT_DEBUG_INTERACTIVE)
    1.18 +exec 6>&1 7>&2 8<&0
    1.19  #  - then point stdout to the log file
    1.20  tmp_log_file="${CT_TOP_DIR}/build.log"
    1.21  rm -f "${tmp_log_file}"