From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26987 invoked by alias); 14 Jul 2005 23:32:37 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 26950 invoked by uid 22791); 14 Jul 2005 23:32:31 -0000 Received: from c-24-61-23-223.hsd1.ma.comcast.net (HELO cgf.cx) (24.61.23.223) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Thu, 14 Jul 2005 23:32:31 +0000 Received: by cgf.cx (Postfix, from userid 201) id 42C8013C12B; Thu, 14 Jul 2005 19:32:30 -0400 (EDT) Date: Thu, 14 Jul 2005 23:32:00 -0000 From: Christopher Faylor To: cygwin@cygwin.com Subject: Re: bug in freopen Message-ID: <20050714233230.GE26336@trixie.casa.cgf.cx> Reply-To: cygwin@cygwin.com References: <071420052313.28844.42D6F19F0007DD6E000070AC22007340760A050E040D0C079D0A@comcast.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <071420052313.28844.42D6F19F0007DD6E000070AC22007340760A050E040D0C079D0A@comcast.net> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-07/txt/msg00718.txt.bz2 On Thu, Jul 14, 2005 at 11:13:35PM +0000, Eric Blake wrote: >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 > >#include >#include >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 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. Hmm. It should be pretty simple to just make this always fail with EBADF. That seems to be a valid thing to do as far as SUSv3 is concerned. I am curious, though, as to the rationale behind this change. I just tried this with -mno-cygwin and it dies with a ENOENT. So, they apparently removed windows-specific code and replaced it with code that doesn't work on windows... cgf -- 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/