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