This is the mail archive of the glibc-bugs@sources.redhat.com 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 libc/682] stdout and file descriptor mismatch after a freopen()


------- 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.


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