public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug stdio/30731] New: freopen unnecessarily flushes read-only streams
@ 2023-08-07 15:13 fweimer at redhat dot com
2023-08-07 15:14 ` [Bug stdio/30731] " fweimer at redhat dot com
2023-08-08 14:01 ` fweimer at redhat dot com
0 siblings, 2 replies; 3+ messages in thread
From: fweimer at redhat dot com @ 2023-08-07 15:13 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30731
Bug ID: 30731
Summary: freopen unnecessarily flushes read-only streams
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: stdio
Assignee: unassigned at sourceware dot org
Reporter: fweimer at redhat dot com
Target Milestone: ---
After
commit 0b727ed4d605d9318cb0d323c88abb0d5a441a9b
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Thu Jul 13 16:43:24 2017 -0300
libio: Flush stream at freopen (BZ#21037)
As POSIX states [1] a freopen call should first flush the stream as if by a
call fflush. C99 (n1256) and C11 (n1570) only states the function should
first close any file associated with the specific stream. Although current
implementation only follow C specification, current BSD and other libc
implementation (musl) are in sync with POSIX and fflush the stream.
This patch change freopen{64} to fflush the stream before actually
reopening
it (or returning if the stream does not support reopen). It also changes
the
Linux implementation to avoid a dynamic allocation on 'fd_to_filename'.
freopen seeks readable in read mode right before closing them. The fflush
machinery has to do this because it's necessary to make a stream's underlying
file descriptor ready for use with the low-level interfaces. But as we close
the stream immediately after, we do not actually need this.
Reported first as a side effect here:
is this a bug in glibc or readpst?
<https://sourceware.org/pipermail/libc-help/2022-November/006335.html>
<https://inbox.sourceware.org/libc-help/2cefc4fa95dd439c2581f4f06d520c004cd33708.camel@bonedaddy.net/>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug stdio/30731] freopen unnecessarily flushes read-only streams
2023-08-07 15:13 [Bug stdio/30731] New: freopen unnecessarily flushes read-only streams fweimer at redhat dot com
@ 2023-08-07 15:14 ` fweimer at redhat dot com
2023-08-08 14:01 ` fweimer at redhat dot com
1 sibling, 0 replies; 3+ messages in thread
From: fweimer at redhat dot com @ 2023-08-07 15:14 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30731
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at sourceware dot org |fweimer at redhat dot com
CC| |fweimer at redhat dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug stdio/30731] freopen unnecessarily flushes read-only streams
2023-08-07 15:13 [Bug stdio/30731] New: freopen unnecessarily flushes read-only streams fweimer at redhat dot com
2023-08-07 15:14 ` [Bug stdio/30731] " fweimer at redhat dot com
@ 2023-08-08 14:01 ` fweimer at redhat dot com
1 sibling, 0 replies; 3+ messages in thread
From: fweimer at redhat dot com @ 2023-08-08 14:01 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=30731
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |INVALID
--- Comment #1 from Florian Weimer <fweimer at redhat dot com> ---
Andreas Schwab pointed out on-list that the current flush-on-read behavior is
required by POSIX. I'm not sure if I agree. But upon second thought, I think
the current behavior is more generally useful.
[PATCH 2/2] libio: Perform write-only fflush as part of freopen (bug 30731)
<https://inbox.sourceware.org/libc-alpha/87ttt9fxdi.fsf@oldenburg.str.redhat.com/T/#u>
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-08-08 14:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-07 15:13 [Bug stdio/30731] New: freopen unnecessarily flushes read-only streams fweimer at redhat dot com
2023-08-07 15:14 ` [Bug stdio/30731] " fweimer at redhat dot com
2023-08-08 14:01 ` fweimer at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).