From 2aa726009091c1903c7be6c47145961b00323d3a Mon Sep 17 00:00:00 2001 From: Thomas Applencourt Date: Tue, 1 Oct 2024 21:18:59 +0000 Subject: [PATCH] correct handling --- xprof/xprof.rb.in | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/xprof/xprof.rb.in b/xprof/xprof.rb.in index d649cc22..adf590b7 100755 --- a/xprof/xprof.rb.in +++ b/xprof/xprof.rb.in @@ -13,7 +13,16 @@ PREFIX = '@prefix@' DATAROOTDIR = File.join(PREFIX, 'share') DATADIR = DATAROOTDIR -$EXIT_CODE_XPROF = 0 +class XprofExitCode + @@exit_code = 0 + def self.update(exit_code) + @@exit_code = exit_code unless exit_code.zero? + end + + def self.get + @@exit_code + end +end $LOAD_PATH.unshift(DATADIR) if File.directory?(DATADIR) require 'open3' @@ -687,7 +696,7 @@ def trace_and_on_node_processing(usr_argv) # Launch User Command begin - $EXIT_CODE_XPROF |= launch_usr_bin(h, usr_argv) + XprofExitCode.update(launch_usr_bin(h, usr_argv)) rescue Errno::ENOENT teardown_lttng(syncd) raise @@ -868,9 +877,9 @@ if __FILE__ == $PROGRAM_NAME if mpi_master? warn("THAPI: Trace location: #{folder}") - $EXIT_CODE_XPROF |= gm_processing(folder) if OPTIONS[:analysis] + XprofExitCode.update(gm_processing(folder)) if OPTIONS[:analysis] end - exit($EXIT_CODE_XPROF) + exit(XprofExitCode.get) end