编码规范修改禁止使用exit函数

Signed-off-by: liduo <liduo29@huawei.com>
This commit is contained in:
liduo
2025-07-02 21:43:25 +08:00
parent 7b854f65da
commit 95eef05279
2 changed files with 7 additions and 3 deletions
+5 -1
View File
@@ -30,7 +30,11 @@ int main(int argc, char *argv[])
PrintError(GetError(ERR_CODE_UNKNOWN_COMMAND_ERROR).FormatCause("argv null"));
return RESTOOL_ERROR;
}
InitFaq(std::string(argv[0]));
try {
InitFaq(std::string(argv[0]));
} catch (const std::runtime_error &error) {
return RESTOOL_ERROR;
}
auto &parser = CmdParser::GetInstance();
return parser.Parse(argc, argv, 1);
}
+2 -2
View File
@@ -635,8 +635,8 @@ std::string ExecuteCommand(const std::string &cmd)
argv[i] = nullptr;
execvp(argv[0], argv);
// if execvp returns, there was an error.
perror("execle failed");
exit(EXIT_FAILURE);
perror("execvp failed");
throw std::runtime_error("execvp failed");
} else {
// parent process
// close unused write end