Hi Monks,

I am really new to Perl and having some issues I don't really know how to handle. I work in a Windows environment.

I made a father script that loops to gather configuration information and provide data files to another program. No real problem here, this task was a good first contact with Perl (XML reading and writing, regex...).

My problem is that this program doesn't end on its own, it has to run for a certain duration(which I get in the conf files) so the standards functions like open(), exec(), or system() can't help here as I need to ask the program to stop (in a clean way) and those will just have my script start to wait. I could have set a timeout but the duration set in the files may change while the program is already running so I have to update it.

Also I need to start several instances of the external program as new conf files become available and all this may get even more complicated after the first prototype development phase as the instances of the external program will probably have to be distributed across several servers (it is a quite memory consuming app), this will be a problem to be adressed later but it may influence the choice here.

I have looked for ideas and found some modules that look like they could help me here but I feel a bit overwhelmed by all this information :p

- Win32::Job

- POE

- IPC::Cmd

Or I could make a "double fork", one to start the program, the other one to process its output files and close it when the time has come (I would need to find the right cmd window (probably thanks to its title) and emulate a click on the cross or a Ctrl-C to end it properly).

Which one of the above approaches seems the best suited fo my needs (and being reasonably easy to put to use for the confused beginner I am) ? Do you know other modules that could do the job? Do you have any general advice/examples for this situation ?

Thank you in advance for your wisdom !

Porax


In reply to Managing an asynchronous neverending external program by Porax

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.