Skip to content

Commit

Permalink
fix: run init error
Browse files Browse the repository at this point in the history
  • Loading branch information
unkn0wName authored and unkn0wName committed Apr 4, 2023
1 parent 155bc1e commit 7ab9f55
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions testRoot/init64_process_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,32 @@ static std::string safe_run_init64_cmd_wrapper(
const char* str_root_key,
const char *cmd,
ssize_t & out_err) {
pid_t target_pid = 1;
return safe_inject_process64_run_cmd_wrapper(str_root_key, target_pid,
cmd, out_err);
std::string str_cmd_result;
if (cmd == NULL || strlen(cmd) == 0) { return {}; }

fork_pipe_info finfo;
if (fork_pipe_child_process(finfo)) {
out_err = 0;
str_cmd_result = run_init64_cmd_wrapper(
str_root_key,
cmd,
out_err);
write_errcode_to_father(finfo, out_err);
write_string_to_father(finfo, str_cmd_result);
_exit(0);
return {};
}

out_err = 0;
if (!wait_fork_child_process(finfo)) {
out_err = -64001;
} else {
if (!read_errcode_from_child(finfo, out_err)) {
out_err = -64002;
} else if (!read_string_from_child(finfo, str_cmd_result)) {
out_err = -64003;
}
}
return str_cmd_result;
}
#endif /* INIT64_HELPER_H_ */

0 comments on commit 7ab9f55

Please sign in to comment.