delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/02/18/22:02:38

From: cgf AT bbc DOT com (Christopher Faylor)
Subject: Re: freopen bug?
18 Feb 1998 22:02:38 -0800 :
Message-ID: <EoLuF3.DBD.cygnus.cygwin32.developers@bbc.com>
References: <EoK9xI DOT Foz AT bbc DOT com>
Reply-To: cgf AT bbc DOT com
To: cygwin32-developers AT cygnus DOT com

In article <199802190037 DOT QAA09366 AT skaro DOT cygnus DOT com>,
Geoffrey Noer  <noer AT cygnus DOT com> wrote:
>Christopher Faylor wrote:
>> 
>> Mumit Khan has indicated that he is having problems getting collect2 to
>> work with EGCS due to an apparent bug in newlib's freopen.
>> 
>> The problem is that freopen is apparently not preserving the fd of the
>> stream that is operating on.
>
>I have committed this patch since it does fix the problem demonstrated
>in your test program.  However, I still have collect2 problems.
>
>//cpp.1
>#include <list.h>
>
>list<int> my_list01;
>
>---------------------------
>
>//cpp.2
>#include <list.h>
>
>int main()
>{
>list<int> my_list02;
>return 0;
>}
>
>------------------------------
>
>If I compile these files using b19:
>	
>	g++ -c -frepo -fno-implicit-templates 1.cpp 2.cpp
>	g++ -frepo 1.o 2.o
>
>the compile fails.  This happens in the same way regardless of the
>behavior of freopen.
>
>Also I just noticed that my g++ et al aren't being installed correctly
>because they aren't getting a .exe suffix appended during build time.
>I'll have to fix the makefiles...

That's too bad.  I guess I should have known it wouldn't be that easy.

I checked out the "Single UNIX" specification for freopen today and it
seems that the newlib freopen is not exactly "up to spec".

According to the man page, freopen *always* closes its stream argument
first before attempting to open the new file.  The newlib freopen seems
to go to some effort to ensure that the stream argument is not closed
until the filename has been opened.

If you remove my patch and just make the freopen close the file prior
to opening the new file, freopen may act more like UNIX.

I don't see why that would fix the collect2 problem, but I think you'll
get a similar effect to my patch -- at least if you're careful when opening
stdin/stdout/stderr.
-- 
http://www.bbc.com/	cgf AT bbc DOT com			"Strange how unreal
VMS=>UNIX Solutions	Boston Business Computing	 the real can be."

- Raw text -


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