greatly improve freopen behavior
authorRich Felker <dalias@aerifal.cx>
Thu, 25 Oct 2012 01:16:06 +0000 (21:16 -0400)
committerRich Felker <dalias@aerifal.cx>
Thu, 25 Oct 2012 01:16:06 +0000 (21:16 -0400)
commit892cafff665b44d238e3b664f61ca38dd965cba6
treec65353fe88b0d78025e113b77ed8728a2b4bc8d4
parent708c91f4e9be2cfd6d35e71361956e13f3201b85
greatly improve freopen behavior

1. don't open /dev/null just as a basis to copy flags; use shared
__fmodeflags function to get the right file flags for the mode.

2. handle the case (probably invalid, but whatever) case where the
original stream's file descriptor was closed; previously, the logic
re-closed it.

3. accept the "e" mode flag for close-on-exec; update dup3 to fallback
to using dup2 so we can simply call __dup3 instead of putting fallback
logic in freopen itself.
src/internal/stdio_impl.h
src/stdio/__fmodeflags.c [new file with mode: 0644]
src/stdio/fopen.c
src/stdio/freopen.c
src/unistd/dup3.c