ex14.pp 487 B

123456789101112131415161718192021222324
  1. Program Example14;
  2. { Program to demonstrate the Fork and WaitPidfunction. }
  3. Uses linux;
  4. Var PID, ExitStatus : Longint;
  5. begin
  6. Writeln ('Spawning a child');
  7. PID:=Fork;
  8. If PID=0 then
  9. begin
  10. Writeln ('Hello From the Child !!');
  11. Writeln ('Exiting with exit status 1 !');
  12. Halt (1);
  13. end
  14. Else
  15. begin
  16. Writeln ('Spawned child with PID : ',PID);
  17. WaitPid (PID,@ExitStatus,0);
  18. Writeln ('Child exited with status : ',ExitStatus shr 8);
  19. end;
  20. end.