summaryrefslogtreecommitdiff
path: root/vest
diff options
context:
space:
mode:
authorGuest_account Guest_account prguest11 <prguest11@taipan.cs>2011-10-20 22:08:35 +0100
committerGuest_account Guest_account prguest11 <prguest11@taipan.cs>2011-10-20 22:08:35 +0100
commit297bbaab2b722e8fa4f83ab433dae8b4e2126d94 (patch)
tree3188e4f5f5d9139f8da9b104912aa40639ec2f74 /vest
parent95e9ea690b87f4648215782e820e177cbe17f18b (diff)
crazy bugs in parallelize
Diffstat (limited to 'vest')
-rwxr-xr-xvest/parallelize.pl24
1 files changed, 15 insertions, 9 deletions
diff --git a/vest/parallelize.pl b/vest/parallelize.pl
index b4783f91..869f430b 100755
--- a/vest/parallelize.pl
+++ b/vest/parallelize.pl
@@ -240,12 +240,11 @@ my $node_count = 0;
my $script = "";
# fork == one thread runs the sentserver, while the
# other spawns the sentclient commands.
-if (my $pid = fork) {
+my $pid = fork;
+if ($pid == 0) { # child
sleep 8; # give other thread time to start sentserver
- $script =
- qq{wait
-$cdcmd$sentclient $host:$port:$key $cmd
-};
+ $script = "$cdcmd$sentclient $host:$port:$key $cmd";
+
if ($verbose){
print STDERR "Client script:\n====\n";
print STDERR $script;
@@ -270,13 +269,18 @@ $cdcmd$sentclient $host:$port:$key $cmd
}
}
}
- waitpid($pid, 0);
- cleanup();
+ print STDERR "CHILD PROCESSES SPAWNED ... WAITING\n";
+ for my $p (@pids) {
+ waitpid($p, 0);
+ }
} else {
# my $todo = "$sentserver -k $key $multiflag $port ";
my $todo = "$sentserver -k $key $multiflag $port $stay_alive_flag ";
if ($verbose){ print STDERR "Running: $todo\n"; }
check_call($todo);
+ print STDERR "Call to $sentserver returned.\n";
+ cleanup();
+ exit(0);
}
sub numof_live_jobs {
@@ -343,16 +347,18 @@ sub launch_job_fork {
push @errors,$errorfile;
push @outs,$outfile;
}
- if (my $pid = fork) {
+ my $pid = fork;
+ if ($pid == 0) {
my ($fh, $scr_name) = get_temp_script();
print $fh $script;
close $fh;
my $todo = "/bin/bash -xeo pipefail $scr_name 1> $outfile 2> $errorfile";
print STDERR "EXEC: $todo\n";
my $out = check_output("$todo");
- print STDERR "RES: $out\n";
unlink $scr_name or warn "Failed to remove $scr_name";
exit 0;
+ } else {
+ push @pids, $pid;
}
}