A.J. Venter ha scritto:
Look in the demo programs shipped with FPC, there is a fully working
demo  daemon called daemon.pp - among other things, it catches the
crucial signals.

A.J.

On 5/29/07, Alvise Nicoletti <[EMAIL PROTECTED]> wrote:
I still got no answers about how capturing the signals on linux.

Searching the wiki I found nothing useful with "linux service",
"signals", "sigkill", and other stuff like that...

I found something googling but I can't work that way...

Someone looked the code? Is that rubbish or it can be a beginning?

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives



Hi, I managed to edit succesfully that demo file doing nearly all I need, except two things: 1) I'd like to put in a log file the signal I catched, whathever it is, is there a way to convert a "sig: longint" in a string? In the case pf the "DoSig" event procedure the case takes it as constants, is there a way to do the inverse and get the constant name?

2) I'd like to manage to catch all the signals, or at least some more (actually i'm interested in the USR1 and USR2).
Who can explain me that piece of code?
sSet := $ffffbffe;
ps1 := @sSet;
fpsigprocmask(sig_block,ps1,nil);

After this I tryed to add some USR1 and USR2 handling in this way, but it don't works probably for the upper mask:
  new(aOld);
  new(aHup);
  new(aTerm);
  new(aUsr1);
  new(aUsr2);
  aTerm^.sa_handler{.sh} := SigactionHandler(@DoSig);

  aTerm^.sa_mask := zerosigs;
  aTerm^.sa_flags := 0;
  {$ifndef BSD}                {Linux'ism}
   aTerm^.sa_restorer := nil;
  {$endif}
  aHup^.sa_handler := SigactionHandler(@DoSig);
  aHup^.sa_mask := zerosigs;
  aHup^.sa_flags := 0;
  {$ifndef BSD}                {Linux'ism}
   aHup^.sa_restorer := nil;
  {$endif}
  aUsr1^.sa_handler := SigactionHandler(@DoSig);
  aUsr1^.sa_mask := zerosigs;
  aUsr1^.sa_flags := 0;
  aUsr2^.sa_handler := SigactionHandler(@DoSig);
  aUsr2^.sa_mask := zerosigs;
  aUsr2^.sa_flags := 0;

  fpSigAction(SIGTERM,aTerm,aOld);
  fpSigAction(SIGHUP,aHup,aOld);
  fpSigAction(SIGTERM,aUsr1,aOld);
  fpSigAction(SIGHUP,aUsr2,aOld);

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to