Bläddra i källkod

+ New procedure SysFlushStdIO (code taken from InternalExit).
* InternalExit: now calls new procedure SysFlushStdIO
* DoneThread: Also calls SysFlushStdIO to avoid loosing output
if standard files are redirected.

git-svn-id: trunk@17798 -

pierre 14 år sedan
förälder
incheckning
2d5ca71a06
3 ändrade filer med 34 tillägg och 23 borttagningar
  1. 29 23
      rtl/inc/system.inc
  2. 1 0
      rtl/inc/systemh.inc
  3. 4 0
      rtl/inc/thread.inc

+ 29 - 23
rtl/inc/system.inc

@@ -847,31 +847,11 @@ Procedure FinalizeHeap;forward;
 {$endif HAS_MEMORYMANAGER}
 {$endif HAS_MEMORYMANAGER}
 {$endif FPC_HAS_FEATURE_HEAP}
 {$endif FPC_HAS_FEATURE_HEAP}
 
 
-
-Procedure InternalExit;
-var
-  current_exit : Procedure;
 {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
 {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
+procedure SysFlushStdIO;
+var
   pstdout : ^Text;
   pstdout : ^Text;
-{$endif}
-{$if defined(MSWINDOWS) or defined(OS2)}
-  i : longint;
-{$endif}
-Begin
-{$ifdef SYSTEMDEBUG}
-  writeln('InternalExit');
-{$endif SYSTEMDEBUG}
-  while exitProc<>nil Do
-   Begin
-     InOutRes:=0;
-     current_exit:=tProcedure(exitProc);
-     exitProc:=nil;
-     current_exit();
-   End;
-  { Finalize units }
-  FinalizeUnits;
-
-{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
+begin
   { Show runtime error and exit }
   { Show runtime error and exit }
   pstdout:=@stdout;
   pstdout:=@stdout;
   If erroraddr<>nil Then
   If erroraddr<>nil Then
@@ -892,6 +872,32 @@ Begin
     Flush(pstdout^);
     Flush(pstdout^);
   if Textrec(StdErr).Mode=fmOutput then
   if Textrec(StdErr).Mode=fmOutput then
     Flush(StdErr);
     Flush(StdErr);
+end;
+{$endif FPC_HAS_FEATURE_CONSOLEIO}
+
+
+Procedure InternalExit;
+var
+  current_exit : Procedure;
+{$if defined(MSWINDOWS) or defined(OS2)}
+  i : longint;
+{$endif}
+Begin
+{$ifdef SYSTEMDEBUG}
+  writeln('InternalExit');
+{$endif SYSTEMDEBUG}
+  while exitProc<>nil Do
+   Begin
+     InOutRes:=0;
+     current_exit:=tProcedure(exitProc);
+     exitProc:=nil;
+     current_exit();
+   End;
+  { Finalize units }
+  FinalizeUnits;
+
+{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
+  SysFlushStdIO;
 {$endif FPC_HAS_FEATURE_CONSOLEIO}
 {$endif FPC_HAS_FEATURE_CONSOLEIO}
 
 
 {$if defined(MSWINDOWS) or defined(OS2)}
 {$if defined(MSWINDOWS) or defined(OS2)}

+ 1 - 0
rtl/inc/systemh.inc

@@ -1093,6 +1093,7 @@ Procedure SysInitExceptions;
 {$endif FPC_HAS_FEATURE_EXCEPTIONS}
 {$endif FPC_HAS_FEATURE_EXCEPTIONS}
 {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
 {$ifdef FPC_HAS_FEATURE_CONSOLEIO}
 procedure SysInitStdIO;
 procedure SysInitStdIO;
+procedure SysFlushStdIO;
 {$endif FPC_HAS_FEATURE_CONSOLEIO}
 {$endif FPC_HAS_FEATURE_CONSOLEIO}
 {$ifndef FPUNONE}
 {$ifndef FPUNONE}
 Procedure SysResetFPU;
 Procedure SysResetFPU;

+ 4 - 0
rtl/inc/thread.inc

@@ -67,6 +67,10 @@ Var
 {$endif HAS_MEMORYMANAGER}
 {$endif HAS_MEMORYMANAGER}
         if MemoryManager.DoneThread <> nil then
         if MemoryManager.DoneThread <> nil then
           MemoryManager.DoneThread();
           MemoryManager.DoneThread();
+{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
+        { Open all stdio fds again }
+        SysFlushStdio;
+{$endif FPC_HAS_FEATURE_CONSOLEIO}
         CurrentTM.ReleaseThreadVars;
         CurrentTM.ReleaseThreadVars;
       end;
       end;