in reply to Re^4: Forking problem (manager)
in thread Forking problem UPDATED
Then use the method I outlined. It is quite simple as far as IPC goes. You could use one of the IPC modules but I think they mostly subtitute one kind of complexity for another in this case rather than actually making things a lot simpler.
It boils down to the basic, typical use of fork and pipe. Parent creates pipe then forks N times. Parent closes read-from side of pipe and each child closes write-to side of pipe. Then parent can write small packets (each packet needs to be send via a separate syswrite, which you can accomplish by just turning on buffer auto flushing for the pipe filehandle and being sure to write the packet with a single print or similar) and each child can read from the pipe and atomically get the next packet and each packet will only go to one child.
I doubt it would be 2 dozen lines of code.
Parent should likely wait for each child after it has finished writing to and closeing the pipe (so it might want to save up the list of PIDs from forking, but it doesn't actually have to).
Each child boils down to a very simple close WRITE_TO; while( <READ_FROM> ) { doStuff( $array[$_] ) }.
- tye
|
|---|