Skip to content

Commit 64f4ea2

Browse files
committed
kconfig: Fix BrokenPipeError warnings in selftests
The kconfig test harness ("make testconfig") was generating BrokenPipeError warnings when running interactive tests like oldaskconfig and oldconfig: /usr/lib/python3/dist-packages/_pytest/unraisableexception.py:85: PytestUnraisableExceptionWarning: Exception ignored in: <_io.BufferedWriter name=12> Traceback (most recent call last): File "/srv/code/scripts/kconfig/tests/conftest.py", line 127, in oldaskconfig return self._run_conf('--oldaskconfig', dot_config=dot_config, ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ interactive=True, in_keys=in_keys) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ BrokenPipeError: [Errno 32] Broken pipe The issue occurred when the test framework attempted to write to stdin after the conf subprocess had already exited. Wrap stdin write operations in try/except to catch BrokenPipeError and stop sending more input. Add explicit flush() after writes so we can see delivery errors immediately. Ignore BrokenPipeError when closing stdin. Explicitly call wait() to validate subprocess termination. Reviewed-by: Nathan Chancellor <nathan@kernel.org> Tested-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20250923213422.1105654-1-kees@kernel.org Signed-off-by: Kees Cook <kees@kernel.org>
1 parent a40282d commit 64f4ea2

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

scripts/kconfig/tests/conftest.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,22 @@ def _run_conf(self, mode, dot_config=None, out_file='.config',
8181
# For interactive modes such as oldaskconfig, oldconfig,
8282
# send 'Enter' key until the program finishes.
8383
if interactive:
84-
ps.stdin.write(b'\n')
84+
try:
85+
ps.stdin.write(b'\n')
86+
ps.stdin.flush()
87+
except (BrokenPipeError, OSError):
88+
# Process has exited, stop sending input
89+
break
90+
91+
# Close stdin gracefully
92+
try:
93+
ps.stdin.close()
94+
except (BrokenPipeError, OSError):
95+
# Ignore broken pipe on close
96+
pass
97+
98+
# Wait for process to complete
99+
ps.wait()
85100

86101
self.retcode = ps.returncode
87102
self.stdout = ps.stdout.read().decode()

0 commit comments

Comments
 (0)