When running a console app in Lazarus, sending Ctlr C (SIGINT) causes to the exception message box on Windows.
This happens in both debug and release builds, so as far as I understand it has nothing to do with the debugger (gdb).
This is useful notification, but it would be nice if there was an option to disable this feature, just as language exceptions can be disabled in the project options.
After googling this question and even reporting it as a possible IDE issue, much to my surprise, I didn't find an answer.
Anybody knows?
P.S. The obvious solutions don't work because the IDE probably intercepts the SIGINT handler after the console window is launched (see below).
program TestCtrlC;
uses
Windows,
SysUtils;
function CtrlBreakHandler(CtrlBreak: boolean): boolean;
begin
WriteLn('CtrlBreakHandler');
end;
function ConsoleCtrlHandler(dwCtrlType: DWORD): WINBOOL; stdcall;
begin
WriteLn('ConsoleCtrlHandler');
end;
begin
WriteLn('Press Ctrl C');
// SysSetCtrlBreakHandler(@CtrlBreakHandler); (* Solution 3 *)
// SetConsoleCtrlHandler(@ConsoleCtrlHandler,true); (* Solution 2 *)
(*
ReadLn;
WriteLn;
ReadLn;
*)
try (* Solution 1 *)
ReadLn;
WriteLn;
ReadLn;
except
on e: Exception do
WriteLn(e.Message); // ESigQuit expected
end;
WriteLn;
end.