mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 07:35:26 +00:00
always ignore sigpipe
This commit is contained in:
@@ -47,19 +47,34 @@ static pthread_t main_thread;
|
|||||||
|
|
||||||
#ifndef HAVE_SIGWAIT
|
#ifndef HAVE_SIGWAIT
|
||||||
static void
|
static void
|
||||||
empty_action(int arg) {
|
no_action(int arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static isc_result_t
|
||||||
|
handle_signal(int sig, void (*handler)(int)) {
|
||||||
|
struct sigaction sa;
|
||||||
|
|
||||||
|
memset(&sa, 0, sizeof sa);
|
||||||
|
sa.sa_handler = handler;
|
||||||
|
|
||||||
|
if (sigfillset(&sa.sa_mask) != 0 ||
|
||||||
|
sigaction(sig, &sa, NULL) < 0) {
|
||||||
|
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||||
|
"handle_signal() %d setup: %s", sig,
|
||||||
|
strerror(errno));
|
||||||
|
return (ISC_R_UNEXPECTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (ISC_R_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
isc_result_t
|
isc_result_t
|
||||||
isc_app_start(void) {
|
isc_app_start(void) {
|
||||||
isc_result_t result;
|
isc_result_t result;
|
||||||
int presult;
|
int presult;
|
||||||
sigset_t sset;
|
sigset_t sset;
|
||||||
#ifndef HAVE_SIGWAIT
|
|
||||||
struct sigaction sa;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start an ISC library application.
|
* Start an ISC library application.
|
||||||
@@ -94,24 +109,21 @@ isc_app_start(void) {
|
|||||||
* the default actions, regardless of what we do with
|
* the default actions, regardless of what we do with
|
||||||
* pthread_sigmask().
|
* pthread_sigmask().
|
||||||
*/
|
*/
|
||||||
memset(&sa, 0, sizeof sa);
|
result = handle_signal(SIGINT, no_action);
|
||||||
sa.sa_handler = empty_action;
|
if (result != ISC_R_SUCCESS)
|
||||||
if (sigfillset(&sa.sa_mask) != 0 ||
|
return (result);
|
||||||
sigaction(SIGINT, &sa, NULL) < 0) {
|
result = handle_signal(SIGTERM, no_action);
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
if (result != ISC_R_SUCCESS)
|
||||||
"isc_app_run() SIGINT setup: %s",
|
return (result);
|
||||||
strerror(errno));
|
|
||||||
return (ISC_R_UNEXPECTED);
|
|
||||||
}
|
|
||||||
if (sigfillset(&sa.sa_mask) != 0 ||
|
|
||||||
sigaction(SIGTERM, &sa, NULL) < 0) {
|
|
||||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
|
||||||
"isc_app_run() SIGTERM setup: %s",
|
|
||||||
strerror(errno));
|
|
||||||
return (ISC_R_UNEXPECTED);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Always ignore SIGPIPE.
|
||||||
|
*/
|
||||||
|
result = handle_signal(SIGPIPE, SIG_IGN);
|
||||||
|
if (result != ISC_R_SUCCESS)
|
||||||
|
return (result);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Block SIGINT and SIGTERM.
|
* Block SIGINT and SIGTERM.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user