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] New: stdout and file descriptor mismatch after a freopen()


Closing stdin with fclose(stdin) and redirecting stdout with freopen(...,stdout)
make stdout associated with file descriptor 0 instead of 1, leading to
non-documented side effects (and even incompatible with documentation supplied
with Linux: the stdin(3) man page). After a discussion (in French) in
fr.comp.lang.c, several users agreed that this could be seen as a bug and should
be fixed. See bug 670 for a testcase.

Note: Of course, stdin and stderr are affected too, and so is the fopen() function.

A correct behavior would be to reserve file descriptors 0, 1 and 2 for stdin,
stdout and stderr at the fopen/fclose/freopen level (the functions defined by
the ISO C standard). If the programmer uses system calls directly, he should
make sure not to break this convention.

-- 
           Summary: stdout and file descriptor mismatch after a freopen()
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: vincent+libc at vinc17 dot org
                CC: glibc-bugs at sources dot redhat dot com


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]