This is the mail archive of the
mailing list for the newlib project.
RE: bug in freopen
- From: "Dave Korn" <dave dot korn at artimi dot com>
- To: <cygwin at cygwin dot com>,<newlib at sourceware dot org>
- Date: Fri, 15 Jul 2005 11:37:54 +0100
- Subject: RE: bug in freopen
>From: Eric Blake
>Sent: 15 July 2005 00:14
> POSIX requires that freopen(NULL, mode, f) reopen f in the new
> mode, and allows implementations the option of not even closing
> f in the first place. But in cygwin, it is failing with EFAULT, which is
> not even one of the errors allowed by POSIX.
> #include <stdio.h>
> #include <errno.h>
> int main(void)
> FILE* f = freopen (NULL, "rb", stdin); /* Ensure that stdin is binary
> */ printf ("file is %s, errno %d:%s\n", f ? "good" : "null", errno,
> return 0;
> CVS coreutils recently switched to this idiom, replacing its former
> use of the nonstandard <io.h> and setmode() with something
> that is required by the standards. But until this bug is fixed, CVS
> coreutils will not work with cygwin. The strace in cygwin shows
> that newlib tried to perform open(NULL), which is the cause of
> the EFAULT.
I could take a look at this over the weekend if nobody gets to it first :)
Can't think of a witty .sigline today....