Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by spazm (Monk)
on May 07, 2010 at 04:29 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2024-03-28 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found