coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: ensure utils support writing to a closed pipe


From: Pádraig Brady
Subject: [PATCH] tests: ensure utils support writing to a closed pipe
Date: Sat, 3 Aug 2024 14:23:14 +0100

* tests/misc/write-errors.sh: A closed pipe is a common scenario,
and should not induce an error.  The general case is discussed at:
https://www.pixelbeat.org/programming/sigpipe_handling.html
---
 tests/misc/write-errors.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/misc/write-errors.sh b/tests/misc/write-errors.sh
index e78d3fdd4..ad963f23c 100755
--- a/tests/misc/write-errors.sh
+++ b/tests/misc/write-errors.sh
@@ -60,6 +60,11 @@ join all_writers built_programs > built_writers || 
framework_failure_
 while read writer; do
   timeout 10 $SHELL -c "$writer > /dev/full"
   test $? = 124 && { fail=1; echo "$writer: failed to exit" >&2; }
+
+  rm -f pipe.err || framework_failure_
+  timeout 10 $SHELL -c "$writer 2>pipe.err | :"
+  { test $? != 0 || test -s pipe.err; } &&
+   { fail=1; cat pipe.err; echo "$writer: failed to write to closed pipe" >&2; 
}
 done < built_writers
 
 Exit $fail
-- 
2.45.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]