Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Parent process finished. How to exit the child process.

by spazm (Monk)
on May 07, 2010 at 04:29 UTC ( #838853=note: print w/replies, xml ) Need Help??

in reply to Parent process finished. How to exit the child process.

Some options:
  1. parent sends kill signal to child when parent processing is complete. Child dies. parent reaps child and exits (or continues, I suppose).
  2. reverse the roll of parent and child. The child does the computing and the parent handles the counting&display. Child exits when complete and parent reaps child via SIG CHLD handler.
if(my $pid=fork){ while(my $c = ReadKey){ #doing something... ; } kill( HUP => $pid ); wait(0); } else { my $count = 0; while(1){ sleep(1); print $count++; } }
if(my $pid=fork){ #parent my $run = 1; $SIG{CHLD} = sub { $deadchildpid = wait; $run = 0 }; my $count = 0; while($run){ sleep(1); print $count++; } } else { #child while(my $c = ReadKey){ #doing something... ; } }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://838853]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2016-10-28 05:33 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (375 votes). Check out past polls.