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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |