If you need the information back at any point, then you have a few options. Sockets, named pipes, temporary files, a data store of some kind (RDBMS, tuple storage, LDAP, etc) or shared memory can work for forked processes. There are lighter-weight ways to pass the data between threads in a multithreaded process.
If I was to take your original track of forking independent processes and needed the information back asynchronously, I'd probably use TCP sockets or a named pipe. I'd set the parent process up to listen and read without blocking using select and set the children up to connect back to the parent. The child can do what it needs, connect to the parent, dump its report across the socket, then exit. The parent can just ignore child processes exiting with $SIG{'CHLD'} = 'IGNORE';. To know which result is from which child, just have the child include its PID as part of the data it sends in its report. Any child that fails to report back within a certain number of seconds can be sent a kill signal and a new child can take its place in the queue. I think having the parent connect to each child is the wrong way to handle this, because you really only need one socket listening instead of one for each child.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.