mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-11 23:06:07 +02:00
* merged v10 version for exit fixes
This commit is contained in:
parent
14e55511c5
commit
ac61b5e55a
@ -5,6 +5,7 @@ unit initc;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
|
|
||||||
{$LINKLIB cygwin}
|
{$LINKLIB cygwin}
|
||||||
{$linklib kernel32}
|
{$linklib kernel32}
|
||||||
|
|
||||||
@ -29,9 +30,20 @@ procedure do_global_dtors;cdecl;external;
|
|||||||
but that one ends with _exit that is system dependent !! }
|
but that one ends with _exit that is system dependent !! }
|
||||||
|
|
||||||
{ avoid loading of cygwin _exit code
|
{ avoid loading of cygwin _exit code
|
||||||
so that exit returns }
|
so that exit returns
|
||||||
|
apparently this is not enough anymore
|
||||||
|
use longjmp instead PM }
|
||||||
|
var
|
||||||
|
entryjmpbuf,exitjmpbuf : jmp_buf;
|
||||||
|
const
|
||||||
|
exitjmpbufset : boolean = false;
|
||||||
|
|
||||||
procedure _exit(status : longint);cdecl;
|
procedure _exit(status : longint);cdecl;
|
||||||
begin
|
begin
|
||||||
|
if exitjmpbufset then
|
||||||
|
longjmp(exitjmpbuf,1)
|
||||||
|
else
|
||||||
|
RunError(status);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure C_exit(status : longint);popstack;external name '_exit';
|
procedure C_exit(status : longint);popstack;external name '_exit';
|
||||||
@ -52,9 +64,17 @@ begin
|
|||||||
stdHandle:=newHandle;
|
stdHandle:=newHandle;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function entry : longint;
|
||||||
|
begin
|
||||||
|
longjmp(entryjmpbuf,1);
|
||||||
|
entry:=0;
|
||||||
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
cygwin_crt0(nil);
|
if setjmp(entryjmpbuf)=0 then
|
||||||
|
begin
|
||||||
|
cygwin_crt0(@entry);
|
||||||
|
end;
|
||||||
{ Reinitialize std handles that can be changed }
|
{ Reinitialize std handles that can be changed }
|
||||||
UpdateStdHandle(TextRec(Input),StdInputHandle,GetStdHandle(STD_INPUT_HANDLE));
|
UpdateStdHandle(TextRec(Input),StdInputHandle,GetStdHandle(STD_INPUT_HANDLE));
|
||||||
UpdateStdHandle(TextRec(Output),StdOutputHandle,GetStdHandle(STD_OUTPUT_HANDLE));
|
UpdateStdHandle(TextRec(Output),StdOutputHandle,GetStdHandle(STD_OUTPUT_HANDLE));
|
||||||
@ -64,17 +84,31 @@ initialization
|
|||||||
finalization
|
finalization
|
||||||
{ should we pass exit code ?
|
{ should we pass exit code ?
|
||||||
its apparently only used by _exit so it doesn't matter PM }
|
its apparently only used by _exit so it doesn't matter PM }
|
||||||
C_exit(0);
|
if setjmp(exitjmpbuf)=0 then
|
||||||
|
begin
|
||||||
|
exitjmpbufset:=true;
|
||||||
|
{ C_exit(errorcode);
|
||||||
|
this code does not work correctly anymore
|
||||||
|
C function _exit is not called at end of exit function
|
||||||
|
thus the code of exit does not return at all
|
||||||
|
disabled PM }
|
||||||
|
end;
|
||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.4 2001-04-23 18:24:45 peter
|
Revision 1.5 2001-09-22 11:15:31 peter
|
||||||
* remove useless define (merged)
|
* merged v10 version for exit fixes
|
||||||
|
|
||||||
Revision 1.3 2000/12/30 17:48:36 peter
|
Revision 1.1.2.4 2001/09/19 15:23:39 pierre
|
||||||
* update std handles after initing c
|
* work for newer cygwin version
|
||||||
|
|
||||||
|
Revision 1.1.2.3 2001/04/23 01:15:44 carl
|
||||||
|
- removed unused and useless ifdef
|
||||||
|
|
||||||
|
Revision 1.1.2.2 2001/04/02 13:30:14 pierre
|
||||||
|
* Remove call to C exit procedure as it does not return anymore
|
||||||
|
|
||||||
|
Revision 1.1.2.1 2000/12/30 17:49:48 peter
|
||||||
|
* update std handles after initializing c
|
||||||
|
|
||||||
Revision 1.2 2000/07/13 11:33:57 michael
|
|
||||||
+ removed logs
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user