+ 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 -
This commit is contained in:
pierre 2011-06-22 16:16:27 +00:00
parent 9c11ee5544
commit 2d5ca71a06
3 changed files with 34 additions and 23 deletions

View File

@ -847,31 +847,11 @@ Procedure FinalizeHeap;forward;
{$endif HAS_MEMORYMANAGER}
{$endif FPC_HAS_FEATURE_HEAP}
Procedure InternalExit;
{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
procedure SysFlushStdIO;
var
current_exit : Procedure;
{$ifdef FPC_HAS_FEATURE_CONSOLEIO}
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 }
pstdout:=@stdout;
If erroraddr<>nil Then
@ -892,6 +872,32 @@ Begin
Flush(pstdout^);
if Textrec(StdErr).Mode=fmOutput then
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}
{$if defined(MSWINDOWS) or defined(OS2)}

View File

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

View File

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