From 64b63dafe3680e56d54b0a22e53759e72387c899 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 7 Nov 2026 15:38:36 -1000 Subject: Catch an ignored SIGPIPE under any shell dash reports a write to a closed pipe as an I/O error and never names a broken pipe, so where sh is dash the test passed with the reset removed. The writer now leaves a marker when it outlives the closed pipe, which it can only do with the signal ignored. That holds under dash, bash and ksh. --- tests/t0303-robustness.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/t0303-robustness.sh b/tests/t0303-robustness.sh index 41681fa..5f247d1 100755 --- a/tests/t0303-robustness.sh +++ b/tests/t0303-robustness.sh @@ -394,22 +394,28 @@ test_expect_success 'a corrupt blob in a collected diff answers the error' ' grep "Unable to complete the request" tmp ' +# Shells word the failed write differently, and dash names no broken pipe at +# all, so the test looks at whether the writer outlived the closed pipe. It +# puts out more than a pipe holds, so it meets the closed end whatever the +# timing, and it is a script of its own because a subshell of ksh stops at +# the failed write even with the signal ignored. test_expect_success 'a filter pipeline sees the default SIGPIPE disposition' ' - write_script pipe.sh <<-\EOF && + write_script writer.sh <<-\EOF && n=0 while test $n -lt 20000 do echo line n=$((n + 1)) - done | head -c 5 + done + echo outlived >"$PWD/outlived" EOF - { - echo "source-filter=exec:$PWD/pipe.sh" && - cat robrc - } >piperc && - cgit_rc piperc "url=rob/tree/file-1" >tmp 2>err && - grep "^Status: 200" tmp && - ! grep -i "broken pipe" err + write_script pipe.sh <<-EOF && + "$PWD/writer.sh" | head -n 1 + EOF + cgitrc_repo piperc rob "source-filter=exec:$PWD/pipe.sh" && + cgit_ok piperc "url=rob/tree/file-1" >tmp && + test_grep "
line$" tmp &&
+	test_path_is_missing outlived
 '
 
 test_expect_success 'the fallback branch skips a name spelled like an option' '
-- 
cgit 2.12.1