Skip to content

Commit

Permalink
do not ignore return values
Browse files Browse the repository at this point in the history
  • Loading branch information
Karsten1987 committed Dec 12, 2018
1 parent a34c4d9 commit ebd1cc9
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,20 @@ using ProcessHandle = int;
int execute_and_wait_until_completion(const std::string & command, const std::string & path)
{
char previous_dir[PATH_MAX];
getcwd(previous_dir, PATH_MAX);
auto ret_get_cwd = getcwd(previous_dir, PATH_MAX);
if (ret_get_cwd == NULL) {
return EXIT_FAILURE;
}

chdir(path.c_str());
auto ret_ch_dir = chdir(path.c_str());
if (ret_ch_dir != 0) {
return EXIT_FAILURE;
}
auto exitcode = std::system(command.c_str());
chdir(previous_dir);
ret_ch_dir = chdir(previous_dir);
if (ret_ch_dir != 0) {
return EXIT_FAILURE;
}

return WEXITSTATUS(exitcode);
}
Expand Down

0 comments on commit ebd1cc9

Please sign in to comment.