This is the mail archive of the
glibc-bugs@sources.redhat.com
mailing list for the glibc project.
[Bug libc/682] stdout and file descriptor mismatch after a freopen()
- From: "vincent+libc at vinc17 dot org" <sourceware-bugzilla at sources dot redhat dot com>
- To: glibc-bugs at sources dot redhat dot com
- Date: 14 Feb 2005 17:30:44 -0000
- Subject: [Bug libc/682] stdout and file descriptor mismatch after a freopen()
- References: <20050119161710.682.vincent+libc@vinc17.org>
- Reply-to: sourceware-bugzilla at sources dot redhat dot com
------- Additional Comments From vincent+libc at vinc17 dot org 2005-02-14 17:30 -------
I propose the following idea:
* open() always returns fd > 2 (or -1 if an error occurred). [*]
* If fp is stdin, stdout or stderr, then freopen() uses open() + dup2().
i.e. the only way to get a fd <= 2 (corresponding to a standard stream) is to
force this with dup2().
[*] This would require a kernel fix, I suppose. Otherwise, just make sure that
fd > 2 if fopen() is used (for instance, by reassigning the fd with dup2()).
This wouldn't eliminate the race condition though, but pure C programs would
work as expected.
--
http://sources.redhat.com/bugzilla/show_bug.cgi?id=682
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.