dev_container: Fix SIGINT pass-through

In contrast to docker, podman will not pass-through SIGINT unless
--interactive is specified.
This change enables interactive mode by default if a tty is present,
and allows Luci builders to disable this behavior with the new
--no-interactive flag.

BUG=b:275613273
TEST=dev_container presubmit - then CTRL-C

Change-Id: Ic4900a0669b8c423316196abb289516aa618101d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4818790
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
Dennis Kempin 2023-08-28 13:11:34 -07:00 committed by crosvm LUCI
parent ca35151bc1
commit 5d0da2e3cd

View file

@ -200,7 +200,6 @@ def main(argv: List[str]):
parser.add_argument("--stop", action="store_true")
parser.add_argument("--clean", action="store_true")
parser.add_argument("--hermetic", action="store_true")
parser.add_argument("--interactive", action="store_true")
parser.add_argument("--no-interactive", action="store_true")
parser.add_argument("--use-docker", action="store_true")
parser.add_argument("--self-test", action="store_true")
@ -276,18 +275,12 @@ def main(argv: List[str]):
command = args.command
# If a command is provided run non-interactive unless explicitly asked for.
tty_args = []
if not args.no_interactive:
if not command or args.interactive:
if not sys.stdin.isatty():
raise Exception(
"Trying to run an interactive session in a non-interactive terminal."
)
tty_args = ["--interactive", "--tty"]
elif sys.stdin.isatty():
# Even if run non-interactively, we do want to pass along a tty for proper output.
tty_args = ["--tty"]
# Default to interactive mode if a tty is present.
tty_args: List[str] = []
if sys.stdin.isatty():
tty_args += ["--tty"]
if not args.no_interactive:
tty_args += ["--interactive"]
# Start an interactive shell by default
if args.hermetic: