Browse Source

Fix handling of ctrl-c/ctrl-break on go32v2:
* the default handler now silently quits if CtrlBreakHandler returns false or
it hasn't been installed, instead of generating an unknown RTE 0.
Compiler: signal handlers are declared cdecl on go32v2 too.
This fixes bug #11494.

git-svn-id: trunk@11272 -

giulio 17 years ago
parent
commit
5998ab33f2
2 changed files with 21 additions and 3 deletions
  1. 1 1
      compiler/catch.pas
  2. 20 2
      rtl/go32v2/dpmiexcp.pp

+ 1 - 1
compiler/catch.pas

@@ -65,7 +65,7 @@ uses
 {$ifdef unix}
 {$ifdef unix}
 Procedure CatchSignal(Sig : Longint);cdecl;
 Procedure CatchSignal(Sig : Longint);cdecl;
 {$else}
 {$else}
-Function CatchSignal(Sig : longint):longint;
+Function CatchSignal(Sig : longint):longint; cdecl;
 {$endif}
 {$endif}
 begin
 begin
   case Sig of
   case Sig of

+ 20 - 2
rtl/go32v2/dpmiexcp.pp

@@ -1544,6 +1544,23 @@ begin
 {$endif CREATE_C_FUNCTIONS}
 {$endif CREATE_C_FUNCTIONS}
 end.
 end.
 {$else IN_SYSTEM}
 {$else IN_SYSTEM}
+
+{ Default handler for SIGINT. Default action is to quit silently.
+  However, if a CtrlBreakHandler has been installed, call it and continue if
+  it returned true.
+  If you want RTE 217 to be generated, use HandleException instead as the
+  SIGINT handler }
+function SIGINT_Handler(x:longint):longint;cdecl;
+var
+  iscbreak : boolean;
+begin
+  iscbreak:=assigned(djgpp_exception_state_ptr) and
+    (djgpp_exception_state_ptr^.__signum=$1b);
+  if assigned(CtrlBreakHandler) and CtrlBreakHandler(iscbreak) then
+    exit(0); //no need to do cleanups, dpmi_longjmp will do it for us
+  halt;
+end;
+
 const
 const
   FPU_ControlWord : word = $1332;
   FPU_ControlWord : word = $1332;
 function HandleException(sig : longint) : longint;cdecl;
 function HandleException(sig : longint) : longint;cdecl;
@@ -1608,8 +1625,9 @@ begin
    17,                     {'Alignment Check',}
    17,                     {'Alignment Check',}
    18,                     {'Machine Check',}
    18,                     {'Machine Check',}
    19,                     {'SSE FP error'}
    19,                     {'SSE FP error'}
-   SIGSEGV,SIGTRAP,SIGTIMR,SIGINT,SIGQUIT,SIGILL:
+   SIGSEGV,SIGTRAP,SIGTIMR,SIGQUIT,SIGILL:
      ErrorOfSig:=216;
      ErrorOfSig:=216;
+   $1b, $79, SIGINT : ErrorOfSig:=217;
   end;
   end;
   if assigned(djgpp_exception_state_ptr) then
   if assigned(djgpp_exception_state_ptr) then
     Begin
     Begin
@@ -1633,7 +1651,7 @@ begin
   Signal(SIGNOFP,@HandleException);
   Signal(SIGNOFP,@HandleException);
   Signal(SIGTRAP,@HandleException);
   Signal(SIGTRAP,@HandleException);
   Signal(SIGTIMR,@HandleException);
   Signal(SIGTIMR,@HandleException);
-  Signal(SIGINT,@HandleException);
+  Signal(SIGINT,@SIGINT_Handler);
   Signal(SIGQUIT,@HandleException);
   Signal(SIGQUIT,@HandleException);
   Signal(SIGILL,@HandleException);
   Signal(SIGILL,@HandleException);
 end;
 end;