cvs commit: perlfaq perlfaq8.pod

[email protected]
Newsgroups perl.cvs.perlfaq
Message-ID <[email protected]>
cvsuser     02/06/20 21:33:43

  Modified:    .        perlfaq8.pod
  Log:
  * How do I start a process in the background?
  
  	+ added double fork example that used to be in perlfunc's entry
  	for fork.
  
  	+ mentioned the IGNORE value for $SIG{CHLD}
  
  Revision  Changes    Path
  1.9       +18 -2     perlfaq/perlfaq8.pod
  
  Index: perlfaq8.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq8.pod,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -w -r1.8 -r1.9
  --- perlfaq8.pod	16 May 2002 12:41:42 -0000	1.8
  +++ perlfaq8.pod	21 Jun 2002 04:33:43 -0000	1.9
  @@ -1,6 +1,6 @@
   =head1 NAME
   
  -perlfaq8 - System Interaction ($Revision: 1.8 $, $Date: 2002/05/16 12:41:42 $)
  +perlfaq8 - System Interaction ($Revision: 1.9 $, $Date: 2002/06/21 04:33:43 $)
   
   =head1 DESCRIPTION
   
  @@ -375,9 +375,25 @@
   
   =item Zombies
   
  -You have to be prepared to "reap" the child process when it finishes
  +You have to be prepared to "reap" the child process when it finishes.
   
       $SIG{CHLD} = sub { wait };
  +    
  +    $SIG{CHLD} = 'IGNORE';
  +    
  +You can also use a double fork. You immediately wait() for your 
  +first child, and the init daemon will wait() for your grandchild once 
  +it exits.
  +
  +	unless ($pid = fork) {
  +		unless (fork) {
  +            exec "what you really wanna do";
  +            die "exec failed!";
  +        	}
  +        exit 0;
  +    	}
  +    waitpid($pid,0);
  +
   
   See L<perlipc/"Signals"> for other examples of code to do this.
   Zombies are not an issue with C<system("prog &")>.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.