Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Load-sharing parent

by FloydATC (Deacon)
on Dec 08, 2014 at 17:43 UTC ( [id://1109613]=note: print w/replies, xml ) Need Help??


in reply to Load-sharing parent

The simplest way is to use a module as suggested, but if you want to invent your own wheel it's not very difficult. Simply have your master process keep the return value (pid) every time you fork(), use it as a hash key and regularly use waitpid() to check for finished child processes. The hash can be used for keeping track of whatever each child is tasked with. Cleaning up after a child could include reading back results before deleting the hash key.

If you don't like the waitpid() looping you could also rely on a signal handler, but in practice I find this is a little more tricky to get 100% right.

-- FloydATC

Time flies when you don't know what you're doing

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-18 22:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found