1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#!/usr/bin/perl
# test program for Proc::Reliable.
# runs the 'test2slave' program as a subprocess.
my($PROGRAMDIR, $PROGRAMFILE); # dir/file executed by user
BEGIN {
($PROGRAMDIR = $0) =~ s/([^\/]+)$//;
$PROGRAMFILE = $1;
if($PROGRAMDIR eq "") {$PROGRAMDIR = "."}
unshift(@INC, $PROGRAMDIR); # add program dir to module search path
}
use Proc::Reliable;
$SIG{PIPE} = sub { print(STDERR "\n<SIGPIPE>\n"); };
$myproc = Proc::Reliable->new(input_chunking => 1);
for($i=0; $i<7; $i++) {
$stdin .= "test$i\n";
}
print("stdin size: ",length($stdin),"\n");
($out, $err, $status, $msg) = $myproc->run("./test2slave", $stdin);
print("OUT:\n$out\n");
print("ERR:\n$err\n");
print("STATUS:\n$status\n");
print("MSG:\n$msg\n");
|