When I compile and run the following program:
"Hello world" precedes the directory listing if standard output goes to the
console
"Hello world" follows the directory listing if standard output is redirected to
a file
g95 avoids this inconsistency by flushing all buffers before executing "CALL
SYSTEM"
PROGRAM test_system
PRINT *, "Hello world"
CALL SYSTEM("ls")
END PROGRAM test_system
--
Summary: CALL SYSTEM produces garbled output when writing to a
buffered file
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: michael dot a dot richmond at nasa dot gov
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31607