nghttpx: Use _Exit when exiting from child process

This commit is contained in:
Tatsuhiro Tsujikawa 2015-09-24 23:57:24 +09:00
parent 938fa9a1e2
commit c44587a70c
4 changed files with 16 additions and 12 deletions

View File

@ -244,6 +244,8 @@ void exec_binary(SignalServer *ssv) {
return;
}
// child process
shrpx_signal_unset_master_proc_ign_handler();
rv = shrpx_signal_unblock_all();
@ -251,7 +253,7 @@ void exec_binary(SignalServer *ssv) {
auto error = errno;
LOG(ERROR) << "Unblocking all signals failed: " << strerror(error);
exit(EXIT_FAILURE);
_Exit(EXIT_FAILURE);
}
auto exec_path = util::get_exec_path(get_config()->argc, get_config()->argv,
@ -259,7 +261,7 @@ void exec_binary(SignalServer *ssv) {
if (!exec_path) {
LOG(ERROR) << "Could not resolve the executable path";
exit(EXIT_FAILURE);
_Exit(EXIT_FAILURE);
}
auto argv = make_unique<char *[]>(get_config()->argc + 1);
@ -336,7 +338,7 @@ void exec_binary(SignalServer *ssv) {
if (execve(argv[0], argv.get(), envp.get()) == -1) {
auto error = errno;
LOG(ERROR) << "execve failed: errno=" << error;
exit(EXIT_FAILURE);
_Exit(EXIT_FAILURE);
}
}
} // namespace
@ -699,7 +701,7 @@ pid_t fork_worker_process(SignalServer *ssv) {
auto error = errno;
LOG(FATAL) << "Unblocking all signals failed: " << strerror(error);
exit(EXIT_FAILURE);
_Exit(EXIT_FAILURE);
}
close(ssv->ipc_fd[1]);
@ -708,10 +710,10 @@ pid_t fork_worker_process(SignalServer *ssv) {
if (rv != 0) {
LOG(FATAL) << "Worker process returned error";
exit(EXIT_FAILURE);
_Exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
_Exit(EXIT_SUCCESS);
}
// parent process

View File

@ -42,6 +42,6 @@
#define _Exit(status) _exit(status)
#endif // !HAVE__EXIT
#define DIE() exit(EXIT_FAILURE)
#define DIE() _Exit(EXIT_FAILURE)
#endif // SHRPX_H

View File

@ -454,7 +454,7 @@ int ConnectionHandler::start_ocsp_update(const char *cert_file) {
auto error = errno;
LOG(FATAL) << "Unblocking all signals failed: " << strerror(error);
exit(EXIT_FAILURE);
_Exit(EXIT_FAILURE);
}
dup2(pfd[1], 1);
@ -465,7 +465,7 @@ int ConnectionHandler::start_ocsp_update(const char *cert_file) {
auto error = errno;
LOG(ERROR) << "Could not execute ocsp query command: " << argv[0]
<< ", execve() faild, errno=" << error;
exit(EXIT_FAILURE);
_Exit(EXIT_FAILURE);
}
// unreachable
}
@ -482,7 +482,7 @@ int ConnectionHandler::start_ocsp_update(const char *cert_file) {
auto error = errno;
LOG(FATAL) << "Restoring all signals failed: " << strerror(error);
exit(EXIT_FAILURE);
_Exit(EXIT_FAILURE);
}
if (pid == -1) {

View File

@ -88,6 +88,8 @@ int verify_callback(int preverify_ok, X509_STORE_CTX *ctx) {
}
} // namespace
// This function is meant be called from master process, hence the
// call exit(3).
std::vector<unsigned char>
set_alpn_prefs(const std::vector<std::string> &protos) {
size_t len = 0;
@ -95,7 +97,7 @@ set_alpn_prefs(const std::vector<std::string> &protos) {
for (const auto &proto : protos) {
if (proto.size() > 255) {
LOG(FATAL) << "Too long ALPN identifier: " << proto.size();
DIE();
exit(EXIT_FAILURE);
}
len += 1 + proto.size();
@ -103,7 +105,7 @@ set_alpn_prefs(const std::vector<std::string> &protos) {
if (len > (1 << 16) - 1) {
LOG(FATAL) << "Too long ALPN identifier list: " << len;
DIE();
exit(EXIT_FAILURE);
}
auto out = std::vector<unsigned char>(len);