Skip to content

Commit 1215440

Browse files
Add extra checks in execute_and_wait_until_completion(..) (ros2#1346)
- Add check if process was terminated by the signal or really exited Signed-off-by: Michael Orlov <[email protected]>
1 parent dae4660 commit 1215440

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

rosbag2_test_common/include/rosbag2_test_common/process_execution_helpers_unix.hpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,17 @@ int execute_and_wait_until_completion(const std::string & command, const std::st
6060
if (ret_ch_dir != 0) {
6161
return EXIT_FAILURE;
6262
}
63-
auto exitcode = std::system(command.c_str());
63+
auto status = std::system(command.c_str());
6464
ret_ch_dir = chdir(previous_dir);
6565
if (ret_ch_dir != 0) {
6666
return EXIT_FAILURE;
6767
}
68-
69-
return WEXITSTATUS(exitcode);
68+
EXPECT_EQ(WIFEXITED(status), true) << "status = " << status;
69+
if (WIFSIGNALED(status)) {
70+
// Process terminated by signal
71+
return WTERMSIG(status);
72+
}
73+
return WEXITSTATUS(status);
7074
}
7175

7276
ProcessHandle start_execution(const std::string & command)

0 commit comments

Comments
 (0)