ex65.pp 667 B

123456789101112131415161718192021222324252627282930313233
  1. Program example64;
  2. { Program to demonstrate the SigRaise function.}
  3. uses Unix,BaseUnix;
  4. Var
  5. oa,na : PSigActionRec;
  6. Procedure DoSig(sig : Longint);cdecl;
  7. begin
  8. writeln('Receiving signal: ',sig);
  9. end;
  10. begin
  11. new(na);
  12. new(oa);
  13. na^.sa_handler:=TSigaction(@DoSig);
  14. fillchar(na^.Sa_Mask,sizeof(na^.Sa_Mask),#0);
  15. na^.Sa_Flags:=0;
  16. {$ifdef Linux}
  17. // this member is linux only, and afaik even there arcane
  18. na^.Sa_Restorer:=Nil;
  19. {$endif}
  20. if fpSigAction(SigUsr1,na,oa)<>0 then
  21. begin
  22. writeln('Error: ',fpgeterrno);
  23. halt(1);
  24. end;
  25. Writeln('Sending USR1 (',sigusr1,') signal to self.');
  26. SigRaise(sigusr1);
  27. end.