[gfortran] PR 20179

FX fxcoudert@gmail.com
Tue May 24 14:34:00 GMT 2005


> The difference is that C FILE* io has an extra level of buffering ontop of the
> unix IO later. fclose() guarantees that this has been flushed. For close() it
> doesn't exist so there's nothing to do.

If you open a FILE* stream for a given file descriptor, you should not
close the file descriptor until you're sure that the FILE* stream has
been flushed. Here, the gfortran library does only see the file
descriptor point of view, so there are two options:
  1. manually flush FILE* streams for stdout/stderr
  2. don't close the associated file descriptors

The first is, in my opinion, very ugly. And, to answer Janne's
concerns, there is nothing wrong with not closing file descriptors for
stdout and stderr at the end of a program. In fact, you never close
them explicitly in any C code I know!

FX



More information about the Fortran mailing list