exit 导致退出异常

Signed-off-by: s30051537 <sunxiaoqiang7@huawei.com>
This commit is contained in:
s30051537 2024-11-14 10:43:57 +08:00
parent f10f0adfae
commit 72fbdcba18

View File

@ -434,12 +434,12 @@ int ForkExec(std::vector<std::string> &cmd, std::vector<std::string> *output)
(void)close(pipe_fd[0]);
if (dup2(pipe_fd[1], STDOUT_FILENO) == -1) {
LOGE("dup2 failed");
exit(1);
_exit(1);
}
(void)close(pipe_fd[1]);
execvp(args[0], const_cast<char **>(args.data()));
LOGE("execvp failed errno: %{public}d", errno);
exit(1);
_exit(1);
} else {
(void)close(pipe_fd[1]);
if (output) {
@ -461,6 +461,10 @@ int ForkExec(std::vector<std::string> &cmd, std::vector<std::string> *output)
LOGE("Process exits abnormally");
return E_ERR;
}
if (!WEXITSTATUS(status)) {
LOGE("Process exited with an error");
return E_ERR;
}
}
return E_OK;
}