Created attachment 236309 [details] 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.
https://reviews.freebsd.org/D36427 should fix it
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=44cf1e5eb470380442fa8e240e213a71b8fe81d4 commit 44cf1e5eb470380442fa8e240e213a71b8fe81d4 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-09-02 13:39:38 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-09-03 01:06:41 +0000 libc/stdio: only roll FILE state back on EINTR Reported by: JunT <takimoto-j@kba.biglobe.ne.jp> PR: 266171 Reviewed by: emaste, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D36427 lib/libc/stdio/fflush.c | 3 ++- lib/libc/stdio/fvwrite.c | 5 +++-- lib/libc/stdio/wbuf.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)
Thank you for the quick patch. I've tested the 'main' git branch and I think the problem is fixed; The C program does not output 'foo', and the zsh's test now passes. Will this bug report be closed automatically?
(In reply to JunT from comment #3) No, it will not. Close it yourself after I merge the change to stable/13.
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=2a92854d81a10f02a8e244fe0ea449104bda5400 commit 2a92854d81a10f02a8e244fe0ea449104bda5400 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2022-09-02 13:39:38 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2022-09-09 17:01:53 +0000 libc/stdio: only roll FILE state back on EINTR PR: 266171 (cherry picked from commit 44cf1e5eb470380442fa8e240e213a71b8fe81d4) lib/libc/stdio/fflush.c | 3 ++- lib/libc/stdio/fvwrite.c | 5 +++-- lib/libc/stdio/wbuf.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-)