This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug stdio/15589] freopen would close oldfd even though oldfd is same as newfd
- From: "bugdal at aerifal dot cx" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Sat, 26 Nov 2016 14:41:35 +0000
- Subject: [Bug stdio/15589] freopen would close oldfd even though oldfd is same as newfd
- Auto-submitted: auto-generated
- References: <bug-15589-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=15589
--- Comment #9 from Rich Felker <bugdal at aerifal dot cx> ---
It's most certainly nonsense to close the underlying fd for a stream then
perform any subsequent operations on the stream, but the situation could arise
as an implementation detail when a program is exec'd with the standard streams
closed. In that case, fd 0/1/2 may not be valid but the standard FILE objects
would reference them. I'm not sure whether this should be considered a valid
usage; arguably it's undefined to access the FILE objects in this case.
Alternatively, it's arguable that the implementation should detect this
condition at program start and lock out any access to the FILE objects.
--
You are receiving this mail because:
You are on the CC list for the bug.