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.

In reply to Forking and running all child processes at the same time by chanakya

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.