Commit da47440d authored by antirez's avatar antirez
Browse files

Make sure to reset the signal handler and deliver again the original crashing...

Make sure to reset the signal handler and deliver again the original crashing signal when dumping the stack trace. This will allow to dump the core if core dumping is enabled.
parent d8a717fb
......@@ -1606,6 +1606,7 @@ void segvHandler(int sig, siginfo_t *info, void *secret) {
int i, trace_size = 0;
ucontext_t *uc = (ucontext_t*) secret;
sds infostring;
struct sigaction act;
REDIS_NOTUSED(info);
redisLog(REDIS_WARNING,
......@@ -1627,7 +1628,16 @@ void segvHandler(int sig, siginfo_t *info, void *secret) {
/* free(messages); Don't call free() with possibly corrupted memory. */
if (server.daemonize) unlink(server.pidfile);
_exit(0);
/* Make sure we exit with the right signal at the end. So for instance
* the core will be dumped if enabled. */
sigemptyset (&act.sa_mask);
/* When the SA_SIGINFO flag is set in sa_flags then sa_sigaction
* is used. Otherwise, sa_handler is used */
act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND;
act.sa_handler = SIG_DFL;
sigaction (sig, &act, NULL);
kill(getpid(),sig);
}
void sigtermHandler(int sig) {
......
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