This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug stdio/15589] freopen would close oldfd even though oldfd is same as newfd


https://sourceware.org/bugzilla/show_bug.cgi?id=15589

--- Comment #12 from Paul Eggert <eggert at gnu dot org> ---
It's not a POSIX violation if the shell executes "./a.out <&-" with stdin being
closed. Although the command is not portable as-is and POSIX allows the shell
to act as if the command were "./a.out </dev/null", POSIX doesn't require the
shell to do so. Common shells close stdin (which POSIX also allows) and GNU
utilities should do the right thing in this case. This action by common shells
is what caused coreutils Bug#25029.

For what it's worth, I changed Gnulib to work around the glibc freopen
behavior, which is unexpected by so many uses of freopen that I think it
qualifies as a bug even if it's not a POSIX-conformance issue. This should fix
the coreutils bug. Non-Gnulib-using applications are still vulnerable to the
glibc problem.

The Gnulib patch and followup fix are here:

http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=b947d0524d64b5a139282fd48caa7a866e20513c

http://git.savannah.gnu.org/cgit/gnulib.git/commit/?id=ea96186d0b25c89aab0de3129fc4bb3f7a5ccd37

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]