Skip to content

Commit

Permalink
Add extra checks in execute_and_wait_until_completion(..) (#1346) (#1356
Browse files Browse the repository at this point in the history
)

- Add check if process was terminated by the signal or really exited

Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
(cherry picked from commit 1215440)

Co-authored-by: Michael Orlov <michael.orlov@apex.ai>
  • Loading branch information
mergify[bot] and morlov-apexai authored May 30, 2023
1 parent e5e25e7 commit 4a36e3c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,17 @@ int execute_and_wait_until_completion(const std::string & command, const std::st
if (ret_ch_dir != 0) {
return EXIT_FAILURE;
}
auto exitcode = std::system(command.c_str());
auto status = std::system(command.c_str());
ret_ch_dir = chdir(previous_dir);
if (ret_ch_dir != 0) {
return EXIT_FAILURE;
}

return WEXITSTATUS(exitcode);
EXPECT_EQ(WIFEXITED(status), true) << "status = " << status;
if (WIFSIGNALED(status)) {
// Process terminated by signal
return WTERMSIG(status);
}
return WEXITSTATUS(status);
}

ProcessHandle start_execution(const std::string & command)
Expand Down

0 comments on commit 4a36e3c

Please sign in to comment.