From 25b8e4425066e1c38592a7cf7edbc508d25cb2db Mon Sep 17 00:00:00 2001 From: Dennis Kempin Date: Tue, 25 Apr 2023 14:41:11 -0700 Subject: [PATCH] dev_container: Simplify interactive/tty logic Always enable interactive mode when a tty is present. This allows commands to receive SIGINT. Otherwise, still allocate a pseudo tty to enable proper console output. BUG=b:275613273 TEST=dev_container presubmit - then CTRL-C Change-Id: I7fb5c6897404f7d3e9f70755c237da0fd8b82c41 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4475490 Reviewed-by: Zihan Chen Commit-Queue: Dennis Kempin --- tools/dev_container | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/dev_container b/tools/dev_container index 81e7368aef..c846661176 100755 --- a/tools/dev_container +++ b/tools/dev_container @@ -199,7 +199,6 @@ def main( stop: bool = False, clean: bool = False, hermetic: bool = False, - interactive: bool = False, use_docker: bool = False, self_test: bool = False, pull: bool = False, @@ -268,13 +267,10 @@ def main( docker("pull", f"gcr.io/crosvm-infra/crosvm_dev:{DEV_IMAGE_VERSION}").fg() return - # If a command is provided run non-interactive unless explicitly asked for. - tty_args = [] - if not command or interactive: - if not sys.stdin.isatty(): - raise Exception("Trying to run an interactive session in a non-interactive terminal.") + # Default to interactive mode if a tty is present. + if sys.stdin.isatty(): tty_args = ["--interactive", "--tty"] - elif sys.stdin.isatty(): + else: # Even if run non-interactively, we do want to pass along a tty for proper output. tty_args = ["--tty"]