Reputation: 18242
I have this snippet at the end of my script:
use List::Util qw(min max);
// more stuff..
my $maxReturnCode = max @retCodes;
print "Highest Error Code: $maxReturnCode\n";
exit($maxReturnCode >>8) unless $maxReturnCode == 0;
exit(0);
I add error codes during a threaded compilation:
my $cmd = "$MAKE $MAKE_INVOCATION_PATH/$comp";
my $retCode = system($cmd);
push(@retCodes, $retCode);
However, when I print the highest error code at the end, it's just blank:
01-Apr-2014 06:03:25 Ended At: 06:03 AM
01-Apr-2014 06:03:25
01-Apr-2014 06:03:25 Highest Error Code:
Am I converting this wrong?
Upvotes: 0
Views: 38
Reputation: 385516
$maxReturnCode
is undef because @retCodes
is empty. Either you never reached that push
, or you have two variables named @retCodes
.
You did mention threads, are you trying to pass values from one thread to the other via @retCodes
? Did you make it shared?
Upvotes: 0
Reputation:
The returncode of system() calls is in $?
Use $? >> 8
to get the real exit value of your system call.
my $cmd = "$MAKE $MAKE_INVOCATION_PATH/$comp";
my $retCode = system($cmd);
push(@retCodes, $?>>8) if $retCode;
Upvotes: 1