This is the mail archive of the
mailing list for the GCC project.
Re: PATCH: PR libgfortran/39664: [4.5 Regression] Revision 145571 breaks stdio
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- Cc: "H.J. Lu" <hjl dot tools at gmail dot com>, gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Date: Tue, 07 Apr 2009 02:18:21 +0300
- Subject: Re: PATCH: PR libgfortran/39664: [4.5 Regression] Revision 145571 breaks stdio
- References: <20090406225219.GA27407@lucon.org> <20090406225932.GA73476@troutmask.apl.washington.edu>
Steve Kargl wrote:
On Mon, Apr 06, 2009 at 03:52:19PM -0700, H.J. Lu wrote:
STDOUT_FILENO, STDERR_FILENO and STDIN_FILENO are handled by C library.
libgfortran shouldn't close them for C library. Before revision 145571,
fd_close handled them correctly. OK for trunk?
By default, stdin is attached to unit 5 and stdout
is attached to unit 6. Does the following work
with your patch?
end program test
! Write 'help' to unit=6, which should create file 'fort.6'
end subroutine sub
It should work, though I haven't tested; when you close unit 6,
libgfortran goes through the motions as usual, deallocating all the unit
structures etc. The only difference is that the corresponding unix fd is
really left open, though the library is led to believe it's closed.
Then when you do the write(6), it sees that there is no unit 6 open, and
opens a new external file (fort.6) which gets assigned whatever fd
open() gives it.