<p dir="ltr">Hello,</p>
<p dir="ltr">What is the secret to use this it on Windows?</p>
<p dir="ltr">I have the following example in C:</p>
<p dir="ltr">==== begin code ===</p>
<p dir="ltr">#include <stdio.h><br>
#include <signal.h><br>
#include <stdlib.h></p>
<p dir="ltr">void sigproc() {<br>
printf("You have pressed Ctrl-C\n");<br>
exit(0);<br>
}</p>
<p dir="ltr">main() {<br>
signal(SIGINT, sigproc);<br>
printf("Use Ctrl-C to quit\n");<br>
for(;;);<br>
}</p>
<p dir="ltr">==== end code ===</p>
<p dir="ltr">So when I use the Ctrl+C command I get the "You have pressed Ctrl-C" in the terminal.</p>
<p dir="ltr">However, using this code (compiled in FPC from trunk):</p>
<p dir="ltr">==== begin code ===</p>
<p dir="ltr">program project1;</p>
<p dir="ltr">{$mode objfpc}{$H+}</p>
<p dir="ltr">uses<br>
signals;</p>
<p dir="ltr"> function sigproc(v: LongInt): longint; cdecl;<br>
begin<br>
WriteLn('You have pressed Ctrl-C');<br>
Result := v;<br>
Halt(0);<br>
end;</p>
<p dir="ltr">begin<br>
signal(SIGINT, @sigproc);<br>
WriteLn('Use Ctrl-C to quit');<br>
while true do ;<br>
end.</p>
<p dir="ltr">==== end code ===</p>
<p dir="ltr">It doesn't work. :-(</p>
<p dir="ltr">The program quits, but I can't get the "You have pressed Ctrl-C".</p>
<p dir="ltr">I can use the `Windows.SetConsoleCtrlHandler()`, but I would be happy to understand how to use the `signals` unit. =)</p>
<p dir="ltr">-- <br>
Silvio Clécio</p>