Add compile option to disable internal handling of fatal signals
By default, charon and its derivatives internally handle the SIGSEGV, SIGILL, and SIGBUS signals raised by threads (segv_handler). Add a compile option so that the signal handling can optionally be done externally. Closes strongswan/strongswan#132.
This commit is contained in:
committed by
Tobias Brunner
parent
71141cc8c9
commit
fe3ae5be5d
@@ -174,6 +174,7 @@ static bool lookup_uid_gid()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef DISABLE_SIGNAL_HANDLER
|
||||
/**
|
||||
* Handle SIGSEGV/SIGILL signals raised by threads
|
||||
*/
|
||||
@@ -189,6 +190,7 @@ static void segv_handler(int signal)
|
||||
DBG1(DBG_DMN, "killing ourself, received critical signal");
|
||||
abort();
|
||||
}
|
||||
#endif /* DISABLE_SIGNAL_HANDLER */
|
||||
|
||||
/**
|
||||
* Print command line usage and exit
|
||||
@@ -372,18 +374,23 @@ int main(int argc, char *argv[])
|
||||
/* handle all arguments */
|
||||
handle_arguments(argc, argv, FALSE);
|
||||
|
||||
/* add handler for SEGV and ILL,
|
||||
* INT, TERM and HUP are handled by sigwaitinfo() in run() */
|
||||
action.sa_handler = segv_handler;
|
||||
/* add handler for fatal signals,
|
||||
* INT, TERM, HUP and USR1 are handled by sigwaitinfo() in run() */
|
||||
action.sa_flags = 0;
|
||||
sigemptyset(&action.sa_mask);
|
||||
sigaddset(&action.sa_mask, SIGINT);
|
||||
sigaddset(&action.sa_mask, SIGTERM);
|
||||
sigaddset(&action.sa_mask, SIGHUP);
|
||||
sigaddset(&action.sa_mask, SIGUSR1);
|
||||
|
||||
/* optionally let the external system handle fatal signals */
|
||||
#ifndef DISABLE_SIGNAL_HANDLER
|
||||
action.sa_handler = segv_handler;
|
||||
sigaction(SIGSEGV, &action, NULL);
|
||||
sigaction(SIGILL, &action, NULL);
|
||||
sigaction(SIGBUS, &action, NULL);
|
||||
#endif /* DISABLE_SIGNAL_HANDLER */
|
||||
|
||||
action.sa_handler = SIG_IGN;
|
||||
sigaction(SIGPIPE, &action, NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user