Skip to content

Commit

Permalink
Add exit code setter
Browse files Browse the repository at this point in the history
  • Loading branch information
loganharbour committed Sep 16, 2024
1 parent 0fb34be commit 91ec1d2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions framework/include/base/MooseApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ class MooseApp : public ConsoleStreamInterface,
*/
int exitCode() const { return _exit_code; }

/**
* Sets the exit code that the application will exit with.
*/
void setExitCode(const int exit_code) { _exit_code = exit_code; }

/**
* Get the parameters of the object
* @return The parameters of the object
Expand Down
6 changes: 3 additions & 3 deletions framework/src/base/MooseApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -1662,8 +1662,8 @@ MooseApp::copyInputs()
const auto return_value = system(cmd.c_str());
if (!WIFEXITED(return_value))
mooseError("Process exited unexpectedly");
_exit_code = WEXITSTATUS(return_value);
if (_exit_code == 0)
setExitCode(WEXITSTATUS(return_value));
if (exitCode() == 0)
Moose::out << "Directory successfully copied into ./" << dst_dir << '\n';
return true;
}
Expand Down Expand Up @@ -1721,7 +1721,7 @@ MooseApp::runInputs()
const auto return_value = system(cmd.c_str());
if (!WIFEXITED(return_value))
mooseError("Process exited unexpectedly");
_exit_code = WEXITSTATUS(return_value);
setExitCode(WEXITSTATUS(return_value));
return true;
}

Expand Down

0 comments on commit 91ec1d2

Please sign in to comment.