ex58.pp 556 B

123456789101112131415161718192021222324252627
  1. Program example58;
  2. { Program to demonstrate the Signal 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 BaseUnix;
  9. Procedure DoSig(sig : cint);cdecl;
  10. begin
  11. writeln('Receiving signal: ',sig);
  12. end;
  13. begin
  14. if fpSignal(SigUsr1,SignalHandler(@DoSig))=signalhandler(SIG_ERR) then
  15. begin
  16. writeln('Error: ',fpGetErrno,'.');
  17. halt(1);
  18. end;
  19. Writeln ('Send USR1 signal or press <ENTER> to exit');
  20. readln;
  21. end.