|We don't bite newbies here... much|
Forking and running all child processes at the same timeby chanakya (Friar)
|on Jun 06, 2005 at 12:11 UTC||Need Help??|
chanakya has asked for the wisdom of the Perl Monks concerning the following question:
Greetings eveyone !!
I have a script which will look in a pre-defined log directory, gets the file names,
processes the files one by one and removes the processed file from the log directory.
Now, I want to split the processing of log files to multiple sub-processes, as the current processing takes longer time.
What I want to do is say, when X.pl executes, the X.pl will look into the log directory and gets
the file names in the log directory. For Example if X.pl finds 3 log files, then it
will fork 3 sub-processes of Y.pl and pass each of the log file as an input to the sub processes of Y.pl
The X.pl will have to wait until all the sub-processes returns. Once all the sub-processes return then the parent, i.e X.pl will get newer filenames and the process continues. And also the most important part is all the three sub-processes should run at the same time and not one after another.
Can anyone tell me how to implement the forking and parent script to wait until the sub-processes return.