This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: PR libgfortran/39664: [4.5 Regression] Revision 145571 breaks stdio
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: fortran at gcc dot gnu dot org
- Date: Mon, 6 Apr 2009 15:52:19 -0700
- Subject: PATCH: PR libgfortran/39664: [4.5 Regression] Revision 145571 breaks stdio
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
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?
Thanks.
H.J.
---
2009-04-06 H.J. Lu <hongjiu.lu@intel.com>
PR libgfortran/39664
* io/unix.c (raw_close): Don't close STDOUT_FILENO,
STDERR_FILENO nor STDIN_FILENO.
Index: libgfortran/io/unix.c
===================================================================
--- libgfortran/io/unix.c (revision 145571)
+++ libgfortran/io/unix.c (working copy)
@@ -344,7 +344,12 @@ raw_close (unix_stream * s)
{
int retval;
- retval = close (s->fd);
+ if (s->fd != STDOUT_FILENO
+ && s->fd != STDERR_FILENO
+ && s->fd != STDIN_FILENO)
+ retval = close (s->fd);
+ else
+ retval = SUCCESS;
free_mem (s);
return retval;
}