fix: end listings quietly when the reader leaves

This commit is contained in:
Abdessamad Derraz committed 2026-10-17 20:50:22 +02:00
1 parent 6c0bcb64f1
commit 55631a2fbc
40 files changed
+155 -38

No files matched your search

+17
View File
@@ -2378,3 +2378,20 @@ from dumpcatalog import ( # noqa: E402,F401
annotate_provenance,
write_provenance_snapshot,
)
def run_cli(main) -> None:
"""Run a command-line entry point to its exit status.
A reader that stops early (`verify.py --all | head`) closed the pipe
and the next write died on a BrokenPipeError traceback. Output nobody
reads any more ends the run quietly, with the status a shell gives a
writer whose reader left.
"""
try:
code = main()
sys.stdout.flush()
except BrokenPipeError:
os.dup2(os.open(os.devnull, os.O_WRONLY), sys.stdout.fileno())
sys.exit(141)
sys.exit(code)