Hello,

What is the secret to use this it on Windows?

I have the following example in C:

==== begin code ===

#include <stdio.h>
#include <signal.h>
#include <stdlib.h>

void sigproc() {
    printf("You have pressed Ctrl-C\n");
    exit(0);
}

main()  {
    signal(SIGINT, sigproc);
    printf("Use Ctrl-C to quit\n");
    for(;;);
}

==== end code ===

So when I use the Ctrl+C command I get the "You have pressed Ctrl-C" in the
terminal.

However, using this code (compiled in FPC from trunk):

==== begin code ===

program project1;

{$mode objfpc}{$H+}

uses
  signals;

  function sigproc(v: LongInt): longint; cdecl;
  begin
    WriteLn('You have pressed Ctrl-C');
    Result := v;
    Halt(0);
  end;

begin
  signal(SIGINT, @sigproc);
  WriteLn('Use Ctrl-C to quit');
  while true do ;
end.

==== end code ===

It doesn't work. :-(

The program quits, but I can't get the "You have pressed Ctrl-C".

I can use the `Windows.SetConsoleCtrlHandler()`, but I would be happy to
understand how to use the `signals` unit. =)

-- 
Silvio Clécio
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to