Skip to contentSkip to conversation

clang-tools: Import os for broken pipe handling

PATCH In review houtinghang 2 participants 5 messages Sep 23 – Sep 30

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clang-tools: Import os for broken pipe handling

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

---
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
scripts/clang-tools/run-clang-tools.py +1 -0
index e78be82..79d58b3 100755
@@ -12,6 +12,7 @@ compile_commands.json.
 import argparse
 import json
 import multiprocessing
+import os
 import subprocess
 import sys
 
scripts/clang-tools/run-clang-tools_test.py new file +41 -0

41 lines not on this page · raw message

base-commit: fe2ec83746e501645709761605c2464a44fd2929

Signature · 1 line
2.52.0.windows.1
#1 lore raw

scripts/clang-tools/run-clang-tools_test.py

Quoted 39 lines · houtinghang

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

---
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
scripts/clang-tools/run-clang-tools.py +1 -0
index e78be82..79d58b3 100755
@@ -12,6 +12,7 @@ compile_commands.json.
 import argparse
 import json
 import multiprocessing
+import os
 import subprocess
 import sys
 
scripts/clang-tools/run-clang-tools_test.py +0 -0

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.

Signature · 2 lines
Cheers,
Nathan
#2 lore raw

PATCH 1/1 clang-tools: Import os for broken pipe handling

From: Ting-Han Hou <[email protected]>

The BrokenPipeError handler in run-clang-tools.py calls os.open() and os.dup2() without importing os. If this handler is reached, it raises NameError instead of redirecting stdout and exiting with status 1.

Import os so the handler can work as intended.

Fixes 87c7ee67deb7 ("scripts: handle BrokenPipeError for python scripts")
Assisted-by LLM
---
 scripts/clang-tools/run-clang-tools.py | 1 +
 1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/scripts/clang-tools/run-clang-tools.py
index e78be82..79d58b3 100755

scripts/clang-tools/run-clang-tools.py +1 -0
@@ -12,6 +12,7 @@ compile_commands.json.
 import argparse
 import json
 import multiprocessing
+import os
 import subprocess
 import sys
 

base-commit: fe2ec83746e501645709761605c2464a44fd2929

Signature · 1 line
2.52.0.windows.1
#3 lore raw

scripts/clang-tools/run-clang-tools.py

Quoted 17 lines · On 2026-09-26 08:52 +0800, 14侯廷翰 wrote:

From: Ting-Han Hou <[email protected]>

The BrokenPipeError handler in run-clang-tools.py calls os.open() and os.dup2() without importing os. If this handler is reached, it raises NameError instead of redirecting stdout and exiting with status 1.

Import os so the handler can work as intended.

Fixes 87c7ee67deb7 ("scripts: handle BrokenPipeError for python scripts")
Assisted-by LLM
---
 scripts/clang-tools/run-clang-tools.py | 1 +
 1 file changed, 1 insertion(+)
scripts/clang-tools/run-clang-tools.py +0 -0

Your patch is mangled, so it cannot be applied (maybe you send it with a different client from your v1?). Please resend properly.

Signature · 2 lines
Cheers,
Nathan
#4 lore raw

From: Ting-Han Hou <[email protected]>
Date: Sat, 26 Sep 2026 08:52:24 +0800
Subject: [PATCH] clang-tools: Import os for broken pipe handling

The BrokenPipeError handler in run-clang-tools.py calls os.open() and os.dup2() without importing os. If this handler is reached, it raises NameError instead of redirecting stdout and exiting with status 1.

Import os so the handler can work as intended.

Fixes 87c7ee67deb7 ("scripts: handle BrokenPipeError for python scripts")
Assisted-by LLM

---
Hi Nathan,

Sorry about the formatting issue. The diff header was wrapped in my previous email. Here is the corrected patch; the code change is unchanged.

Thanks,
Ting-Han

 scripts/clang-tools/run-clang-tools.py | 1 +
 1 file changed, 1 insertion(+)
(quoted diff) +0 -0

b/scripts/clang-tools/run-clang-tools.py
index e78be82..79d58b3 100755

scripts/clang-tools/run-clang-tools.py +1 -0
@@ -12,6 +12,7 @@ compile_commands.json.
 import argparse
 import json
 import multiprocessing
+import os
 import subprocess
 import sys
 

base-commit: fe2ec83746e501645709761605c2464a44fd2929

Signature · 1 line
2.52.0.windows.1
Quoted 25 lines · Nathan Chancellor

scripts/clang-tools/run-clang-tools.py

Quoted 17 lines · On 2026-09-26 08:52 +0800, 14侯廷翰 wrote:

From: Ting-Han Hou <[email protected]>

The BrokenPipeError handler in run-clang-tools.py calls os.open() and os.dup2() without importing os. If this handler is reached, it raises NameError instead of redirecting stdout and exiting with status 1.

Import os so the handler can work as intended.

Fixes 87c7ee67deb7 ("scripts: handle BrokenPipeError for python scripts")
Assisted-by LLM
---
 scripts/clang-tools/run-clang-tools.py | 1 +
 1 file changed, 1 insertion(+)
scripts/clang-tools/run-clang-tools.py +0 -0

Your patch is mangled, so it cannot be applied (maybe you send it with a different client from your v1?). Please resend properly.

--
Cheers,
Nathan