From b069ded58275ccb19d01b7dfa9944f27f0b4bb4d Mon Sep 17 00:00:00 2001 From: Ruben Herold Date: Sun, 9 Aug 2026 23:06:47 +0200 Subject: utils: T9185: fix ask_yes_no() busy-looping forever on non-tty stdin commit-confirm (and ~40 other call sites) hang and burn a full CPU core indefinitely when invoked with stdin that isn't a TTY, e.g. a non-interactive vbash session (vbash -c "... commit-confirm 10; exit"). input() raises EOFError immediately and repeatedly in that case, and the except handler in ask_yes_no() looped straight back to input() with no backoff or exit condition. Check stdin.isatty() up front and return the default immediately when it's not a TTY, matching what a user pressing Enter (accepting the default) would already do interactively. --- python/vyos/utils/io.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/vyos/utils/io.py b/python/vyos/utils/io.py index 77e30cbb0..13ef8709a 100644 --- a/python/vyos/utils/io.py +++ b/python/vyos/utils/io.py @@ -56,7 +56,10 @@ def ask_input(question, default='', numeric_only=False, valid_responses=[], def ask_yes_no(question, default=False) -> bool: """Ask a yes/no question via input() and return their answer.""" - from sys import stdout + from sys import stdin, stdout + + if not stdin.isatty(): + return default default_msg = "[Y/n]" if default else "[y/N]" while True: try: -- cgit v1.2.3