This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Flushing libgfortran from C


On 03/03/2011 09:37 AM, Yuri Gribov wrote:
The problem is that CAF_EXIT does _exit() internally (don't ask me
why) which bypasses all registered exit handlers including
libgfortran's destructor (cleanup in runtime/main.c). This seems to
cause problems with Fortran IO: I tried all sorts of fflushes, fsyncs
and sleeps in CAF_EXIT but neither of them makes libgfortran print
it's internal buffers.
Is there any way to workaround this i.e. to ask libgfortran to flush
(from C program)? I know about `call flush()' and environment
variables but these really solve different problems and would not be
useful in CAF's case

For flushing the buffer, you could simply call from C: _gfortran_flush_i4 (NULL);

It should solve at least some of your problems. However, I do not understand why you get an empty stdout. To my knowledge, stdout is not buffered. (Unless that's different in 4.4.)

(I admit that having a call which properly shuts down the library would be sometimes useful.)

Tobias


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]