[Bug 266171] Writing to stdout after moving file descriptor 1

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 02 Sep 2022 10:49:53 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266171

            Bug ID: 266171
           Summary: Writing to stdout after moving file descriptor 1
           Product: Base System
           Version: 13.1-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: takimoto-j@kba.biglobe.ne.jp
 Attachment #236309 text/plain
         mime type:

Created attachment 236309
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=236309&action=edit
minimum reproducer

The attached C program gives different output on 13.0 and 13.1.
On 13.1, it gives:

fflush: Bad file descriptor
foo
end

But on 13.0 (and on Linux and macOS) the line 'foo' is not output.
I think this is the correct behavior since file descriptor 1 is closed when
printf("foo\n") is called.

I've noticed this problem while testing zsh. If you build zsh (9.0) and run
'make check' then test A04 will fail on 13.1 due to this problem.

-- 
You are receiving this mail because:
You are the assignee for the bug.