On Tue, Apr 15, 2025 at 9:54 PM Jim Meyering <j...@meyering.net> wrote: > Whoa. Thanks. It looks like this is a >19-year-old bug in stream-close.c > Here's a tentative fix -- the ChangeLog entry still lacks details of > when it was introduced:
- if (! fclose_fail) + if (!fclose_fail && !prev_fail) errno = 0; I wonder if this was intentional? Since close_stdout seems to be mostly used as an atexit function, errno may well have been set for some unrelated reason by the time this runs -- but errno will be relevant to this stream if fclose has just failed. (That's how I made sense of it anyway, on the assumption that it was not a bug)