This is the mail archive of the
mailing list for the GCC project.
Re: [gfortran] PR 20179
> 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!