Subject: | die statement of perl sript as subcommand, passed to IPC::Run causes process to hang |
Hi,
If command to be executed is perl script and perl script die, then IPC::run methods doesnt return. it just hang up.
For example, in the attached perl scripts IPC_run_test.pl uses IPC::run to call transform_sep.pl. if transform_sep.pl die, IPC::Run call in IPC_run_test.pl never return.
it causes process to hang
Details of versions:
perl version : v5.10
IPC::run version : 0.91.
OS : GNU/Linux 2.6.32-358.11.1.el6.x86_64
Subject: | IPC_run_test.pl |
#!/bin/env perl
use IPC::Run qw( run timeout start harness finish pump); # IPC::Run version 0.91
use strict;
use warnings;
use IO::Pipe;
my $write = IO::Handle->new();;
my $read = IO::Handle->new();
$write->autoflush(1);
my $pipe = IO::Pipe->new($read, $write);
my @args = ( [
'/home/dhawal/perl_script/transform_sep.pl',
'--in-seperator', '|',
],
'<' , $read,
'2>','/home/dhawal/log/transform_sep_err.log',
'>', '/home/dhawal/log/transform_sep_out.log'
);
my $h = start (@args);
open(LRGE_FH, '/home/dhawal/data/test_big_data.dat');
while (<LRGE_FH>) {
print $write $_;
}
close ($write);
close ($read);
finish $h;
if ( defined $h->result && $h->result != 0 ) {
print STDERR "Error in executing cmd transform_sep \n";
}
print " IPC::Run::finish completed successfully \n";
exit;
Subject: | test_big_data.dat |
Message body not shown because it is not plain text.
Subject: | transform_sep.pl |
#!/bin/env perl
use strict;
use Getopt::Long;
my $insep = '';
my $outsep = '';
my $result = GetOptions ("in-seperator=s" => \$insep,
"out-seperator=s" => \$outsep,
);
if (!$insep) {
die "Missing args : in-seperator \n";
}
if (!$outsep) {
die "Missing args : out-seperator \n";
}
$insep =~ s/([^\w\\])/\\$1/g;
while (<>) {
chomp();
my @F = split ($insep, $_) ;
print join( $outsep, @F ), "\n";
}