Debian Codegraph @

test1master

raw
1 #!/usr/bin/perl
2
3 # test program for Proc::Reliable.
4 # runs the 'test1slave' 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 push(@INC, $PROGRAMDIR); # add program dir to module search path
13 }
14
15 use Proc::Reliable;
16
17 $SIG{PIPE} = sub { print(STDERR "\n<SIGPIPE>\n"); };
18
19 $myproc = Proc::Reliable->new(num_tries => 3, time_per_try => 4);
20 $myproc->want_single_list(0);
21 $myproc->time_per_try(3);
22 $myproc->num_tries(2);
23 $myproc->time_btw_tries(1);
24 $myproc->maxtime(15);
25 $myproc->allow_shell(1);
26 #$myproc->child_exit_time(2);
27 #$myproc->sigterm_exit_time(0.001);
28 #$myproc->sigkill_exit_time(0.001);
29 for($i=0; $i<5; $i++) {
30 $stdin .= "this is a test of the stdin transmission system $i\n";
31 }
32 print("stdin size: ",length($stdin),"\n");
33 ($out, $err, $status, $msg) = $myproc->run("./test1slave", $stdin);
34 #$out = $myproc->run("./test2", $stdin);
35 #$myproc->run("./test2", $stdin);
36 #$out = $myproc->stdout();
37 #$err = $myproc->stderr();
38 #$status = $myproc->status();
39 #$msg = $myproc->msg();
40 #($out, $err, $status, $msg) = $myproc->run(\&mysub);
41
42 print("OUT:\n$out\n");
43 print("ERR:\n$err\n");
44 print("STATUS:\n$status\n");
45 print("MSG:\n$msg\n");
46
47 sub mysub() {
48 print("started\n");
49 sleep(1);
50 print("stopped\n");
51 print(STDERR "hello\n");
52 return 34;
53 }