Re: [PATCH] clang-tools: Import os for broken pipe handling

From: Nathan Chancellor

Date: Fri Sep 25 2026 - 18:34:52 EST


On 2026-09-23 22:22 +0800, houtinghang wrote:
> The BrokenPipeError handler in run-clang-tools.py calls os.open() and
> os.dup2() without importing os. When the analysis pool raises this
> exception, the handler raises NameError instead of redirecting stdout
> and exiting with status 1.
>
> Import os and add a regression test that injects BrokenPipeError from
> Pool.map(), then checks the redirection and exit status.
>
> Fixes: 87c7ee67deb7 ("scripts: handle BrokenPipeError for python scripts")
> Assisted-by: LLM
> Signed-off-by: houtinghang <ue081723@xxxxxxxxx>
> ---
> Testing: python scripts/clang-tools/run-clang-tools_test.py -v
> The test fails before the import with NameError and passes after it.
> Tested with Python 3.13 on Windows using exception injection; no complete
> kernel build or real clang-tidy pipeline test was performed.
>
> AI disclosure: Codex found the missing import, wrote the fix and test,
> ran the test, reviewed the diff, and drafted this message in response to
> a request to find, fix, review and submit a Linux kernel bug.
>
> scripts/clang-tools/run-clang-tools.py | 1 +
> scripts/clang-tools/run-clang-tools_test.py | 41 +++++++++++++++++++++
> 2 files changed, 42 insertions(+)
> create mode 100644 scripts/clang-tools/run-clang-tools_test.py
>
> diff --git a/scripts/clang-tools/run-clang-tools.py b/scripts/clang-tools/run-clang-tools.py
> index e78be82..79d58b3 100755
> --- a/scripts/clang-tools/run-clang-tools.py
> +++ b/scripts/clang-tools/run-clang-tools.py
> @@ -12,6 +12,7 @@ compile_commands.json.
> import argparse
> import json
> import multiprocessing
> +import os
> import subprocess
> import sys
>
> diff --git a/scripts/clang-tools/run-clang-tools_test.py b/scripts/clang-tools/run-clang-tools_test.py

The change to run-clang-tools.py is obviously correct but I am not sure
this test really adds much other than noise. Please drop it and resend
with an adjusted commit message. Additionally, please adjust your name
in the signoff to be a "known identity" per the Documentation.

--
Cheers,
Nathan