delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/07/15/03:26:30

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
MIME-Version: 1.0
Subject: RE: bug in freopen
Date: Fri, 15 Jul 2005 09:24:32 +0200
Message-ID: <ECDC9C7BC7809340842C0E7FCF48C39310B3C8@MCHP7IEA.ww002.siemens.net>
From: "Schwarz, Konrad" <konrad DOT schwarz AT siemens DOT com>
To: "Eric Blake" <ericblake AT comcast DOT net>, <cygwin AT cygwin DOT com>,
<newlib AT sourceware DOT org>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id j6F7QQRa025013

> -----Original Message-----
> From: newlib-owner AT sources DOT redhat DOT com 
> [mailto:newlib-owner AT sources DOT redhat DOT com] On Behalf Of Eric Blake
> Sent: Friday, July 15, 2005 1:14 AM
> To: cygwin AT cygwin DOT com; newlib AT sourceware DOT org
> Subject: bug in freopen
> 
> 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.
> 
> http://www.opengroup.org/susv3xsh/freopen.html

Just to be pedantic: POSIX allows system interfaces to set <errno> to
values additional to those documented in the standard, so this in itself
is not necessarily a bug.

Of course, freopen() should not be calling open() with NULL, it appears
this case has not been implemented in newlib. 

> 
> #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,
>            strerror(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.
> 
> --
> Eric Blake
> 

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019