ex57.pp 688 B

12345678910111213141516171819202122232425262728293031323334353637
  1. Program example57;
  2. { Program to demonstrate the SigAction function.}
  3. {
  4. do a kill -USR1 pid from another terminal to see what happens.
  5. replace pid with the real pid of this program.
  6. You can get this pid by running 'ps'.
  7. }
  8. uses Linux;
  9. Var
  10. oa,na : PSigActionRec;
  11. Procedure DoSig(sig : Longint);cdecl;
  12. begin
  13. writeln('Receiving signal: ',sig);
  14. end;
  15. begin
  16. new(na);
  17. new(oa);
  18. na^.Handler.sh:=@DoSig;
  19. na^.Sa_Mask:=0;
  20. na^.Sa_Flags:=0;
  21. na^.Sa_Restorer:=Nil;
  22. SigAction(SigUsr1,na,oa);
  23. if LinuxError<>0 then
  24. begin
  25. writeln('Error: ',linuxerror,'.');
  26. halt(1);
  27. end;
  28. Writeln ('Send USR1 signal or press <ENTER> to exit');
  29. readln;
  30. end.