Another way to run applications instead of using exec or fork is to use expect; from the Expect module.
This is very useful for unruly programs that cause your Perl to hang.
I have also used open3 instead of fork / exec but am now currently converting open3 to expect. #Even though it only is available for linux it might be useful to you.

Everything I know is here
http://search.cpan.org/dist/Expect.pm/

Some code that uses this

use Expect; my ($program_name, $login, $sourcefile) = @_; #spawn program_name using perl expect module my $exp = Expect->spawn($program_name,$login) or die "Cannot spawn $program_name $login: $!\n"; #turn off output of results from stdout $exp->log_stdout(0); # wait for program_name to initialise $exp->expect(600,[ qr/Program ready to start/]); # send appropriate command to program_name $exp->send("run program_name $report_name $output_format $source +file \n"); # Wait for report to run or generate an error $exp->expect(600,[ qr/Error/i, sub { my $self = shift; $self->send("quit\n"); print ("perl_program.pl has found an error: + $_ \n"); exp_continue; }], [ qr/Report run successful./i, sub { my $self = shift; $self->send("quit\n"); exp_continue; }]); }

In reply to Re^3: problem with forking by chime
in thread problem with forking by sandeep.ses

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.