Commit 85bc696c authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Add error handling for strdup and sigaction

parent 54bf2256
......@@ -1682,6 +1682,11 @@ int main(int argc, char **argv) {
for (int i = 0; i < argc; ++i) {
mod_config()->argv[i] = strdup(argv[i]);
if (mod_config()->argv[i] == nullptr) {
auto error = errno;
LOG(FATAL) << "failed to copy argv: " << strerror(error);
exit(EXIT_FAILURE);
}
}
mod_config()->cwd = getcwd(nullptr, 0);
......
......@@ -97,8 +97,14 @@ void signal_set_handler(void (*handler)(int), Signals &&sigs) {
struct sigaction act {};
act.sa_handler = handler;
sigemptyset(&act.sa_mask);
int rv;
for (auto sig : sigs) {
sigaction(sig, &act, nullptr);
rv = sigaction(sig, &act, nullptr);
if (rv != 0) {
auto error = errno;
LOG(WARN) << "sigaction() with signal " << sig
<< " failed: errno=" << error;
}
}
}
} // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment