From 20ea7e9d26b2a2db8ea8d31ca14b426da928b1a8 Mon Sep 17 00:00:00 2001 From: Aaron Enye Shi Date: Thu, 16 May 2019 20:36:51 +0000 Subject: [PATCH] Fix hipcc exit code when failing --- bin/hipcc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/bin/hipcc b/bin/hipcc index fadc74c137..012545e5d4 100755 --- a/bin/hipcc +++ b/bin/hipcc @@ -848,7 +848,21 @@ if ($runCmd) { print ("HIP ($HIP_PATH) was built using hcc $hipConfig{'HCC_VERSION'}, but you are using $HCC_HOME/hcc with version $HCC_VERSION from hipcc. Please rebuild HIP including cmake or update HCC_HOME variable.\n") ; die unless $ENV{'HIP_IGNORE_HCC_VERSION'}; } - system ("$CMD") or delete_temp_dirs () and die (); + system ("$CMD"); + if ($? == -1) { + print "failed to execute: $!\n"; + exit($?); + } + elsif ($? & 127) { + printf "child died with signal %d, %s coredump\n", + ($? & 127), ($? & 128) ? 'with' : 'without'; + exit($?); + } + else { + $CMD_EXIT_CODE = $? >> 8; + } + $? or delete_temp_dirs (); + exit($CMD_EXIT_CODE); } # vim: ts=4:sw=4:expandtab:smartindent