home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume26 / tpage2 / startdaemon < prev    next >
Encoding:
Text File  |  1992-06-12  |  595 b   |  30 lines

  1. #! /usr/local/bin/perl4.019
  2.  
  3. # "start daemon" -- Start the tpaged daemon if it isn't running.
  4. #   by Tom Limoncelli, tal@warren.mentorg.com
  5. #   Copyright (c) 1992, Tom Limoncelli
  6.  
  7.  
  8. $BSD = -f '/vmunix';
  9. $pscmd = $BSD ? "ps -auxww" : "ps -ef";
  10.  
  11. open(PS, "$pscmd|") || die "Can't run ps: !$";
  12. $title = <PS>;
  13. $found = 0;
  14. while (<PS>) {
  15.     chop;
  16.     $found = 1 if /tpaged/;
  17. }
  18.  
  19. if (!$found) {
  20.     unless (fork) {    #    this is the child
  21.         unless (fork) {    #    this is the child's child
  22.             sleep 1 until getppid == 1;
  23.             system "/home/adm/lib/tpage/tpaged &";
  24.             exit 0;
  25.         }
  26.         exit 0;
  27.     }
  28.     print "Started tpaged\n";
  29. }
  30.