This was reported downstream for CentOS 9 Stream here: https://bugzilla.redhat.com/show_bug.cgi?id=2112672 The issue is an upstream issue that needs review. The test case is attached from the downstream issue. An strace shows the issue clearly: 1659979752.806415 write(1, "hello\n", 6) = 6 1659979752.806467 write(2, "1. fwrite wrote 6 bytes and ferror is 0\n", 40) = 40 1659979752.806517 write(1, "hello\n", 6) = -1 EPIPE (Broken pipe) 1659979752.806548 --- SIGPIPE {si_signo=SIGPIPE, si_code=SI_USER, si_pid=202616, si_uid=1000} --- 1659979752.806563 write(2, "2. fwrite wrote 6 bytes and ferror is 1\n", 40) = 40 The underlying write fails with EPIPE, but fwrite doesn't itself fail.
Created attachment 14264 [details] test-fwrite.c
POSIX says it shall fail with EPIPE: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fputc.html# "An attempt is made to write to a pipe or FIFO that is not open for reading by any process. A SIGPIPE signal shall also be sent to the thread."
How exactly is the test program called?
(In reply to Andreas Schwab from comment #3) > How exactly is the test program called? ./fwrite -l hello 5000 | head -n1 Such that head terminates and closes the pipe after reading one line.