Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Brubeck Unhammer <unhammer@fsfe.org>2015-04-30 10:23:49 +0300
committerKevin Brubeck Unhammer <unhammer@fsfe.org>2015-04-30 10:33:37 +0300
commitc116fa0dbfd484463318aa05da8ed9ee2c7a2de0 (patch)
treef6b6e31fbe624802fd393f5d91792d8ff1781107 /scripts
parent7c19add821266bc11e1e82176275940c4f2cdebc (diff)
die if the forked extract exited with error
Should we pass on bad exit codes from RunFork to those waitpids as well? Seems like the right thing, though I don't know the code.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generic/extract-parallel.perl26
1 files changed, 24 insertions, 2 deletions
diff --git a/scripts/generic/extract-parallel.perl b/scripts/generic/extract-parallel.perl
index 2b02fa869..5130a8ad3 100755
--- a/scripts/generic/extract-parallel.perl
+++ b/scripts/generic/extract-parallel.perl
@@ -149,9 +149,8 @@ for (my $i = 0; $i < $numParallel; ++$i)
print "glueArg=$glueArg \n";
my $cmd = "$extractCmd $TMPDIR/target.$numStr $TMPDIR/source.$numStr $TMPDIR/align.$numStr $TMPDIR/extract.$numStr $glueArg $otherExtractArgs $weightsCmd --SentenceOffset ".($i*$linesPerSplit)." 2>> /dev/stderr \n";
- print STDERR $cmd;
- `$cmd`;
+ safesystem($cmd) or die;
exit();
}
else
@@ -163,6 +162,10 @@ for (my $i = 0; $i < $numParallel; ++$i)
# wait for everything is finished
foreach (@children) {
waitpid($_, 0);
+ if($? != 0) {
+ print STDERR "ERROR: Failed to execute: @_\n $!\n";
+ exit(1);
+ }
}
# merge
@@ -325,3 +328,22 @@ sub NumStr($)
return $numStr;
}
+sub safesystem {
+ print STDERR "Executing: @_\n";
+ system(@_);
+ if ($? == -1) {
+ print STDERR "ERROR: Failed to execute: @_\n $!\n";
+ exit(1);
+ }
+ elsif ($? & 127) {
+ printf STDERR "ERROR: Execution of: @_\n died with signal %d, %s coredump\n",
+ ($? & 127), ($? & 128) ? 'with' : 'without';
+ exit(1);
+ }
+ else {
+ my $exitcode = $? >> 8;
+ print STDERR "Exit code: $exitcode\n" if $exitcode;
+ return ! $exitcode;
+ }
+}
+