nghttpx: Add error handling for strdup and sigaction
This commit is contained in:
parent
54bf225692
commit
85bc696c38
|
@ -1682,6 +1682,11 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
for (int i = 0; i < argc; ++i) {
|
for (int i = 0; i < argc; ++i) {
|
||||||
mod_config()->argv[i] = strdup(argv[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);
|
mod_config()->cwd = getcwd(nullptr, 0);
|
||||||
|
|
|
@ -97,8 +97,14 @@ void signal_set_handler(void (*handler)(int), Signals &&sigs) {
|
||||||
struct sigaction act {};
|
struct sigaction act {};
|
||||||
act.sa_handler = handler;
|
act.sa_handler = handler;
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
|
int rv;
|
||||||
for (auto sig : sigs) {
|
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
|
} // namespace
|
||||||
|
|
Loading…
Reference in New Issue