home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / languages / perl / nutshell / ch5 / forkdaemon.eg < prev    next >
Encoding:
Text File  |  1992-10-18  |  257 b   |  13 lines

  1. unless (fork) { # this is the child
  2.     unless (fork) { # this is the child's child
  3.     sleep 1 until getppid == 1;
  4.     for (1..1000) {
  5.         system "foo $_";
  6.     }
  7.     exit 0;
  8.     }
  9.     # first child exits quickly
  10.     exit 0;
  11. }
  12. wait; # parent reaps first child quickly
  13.