Skip to content

Commit

Permalink
MDEV-10382 Using systemd, mariadb doesn't restart on crashes
Browse files Browse the repository at this point in the history
when crashing on a signal, don't exit(), but re-signal it, so that
the caller could check WIFSIGNALED()
  • Loading branch information
vuvova committed Dec 6, 2016
1 parent 5142cd5 commit 76546a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sql/signal_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ extern "C" sig_handler handle_fatal_signal(int sig)
if (segfaulted)
{
my_safe_printf_stderr("Fatal " SIGNAL_FMT " while backtracing\n", sig);
_exit(1); /* Quit without running destructors */
goto end;
}

segfaulted = 1;
Expand Down Expand Up @@ -301,9 +301,11 @@ extern "C" sig_handler handle_fatal_signal(int sig)
#ifndef __WIN__
/*
Quit, without running destructors (etc.)
Use a signal, because the parent (systemd) can check that with WIFSIGNALED
On Windows, do not terminate, but pass control to exception filter.
*/
_exit(1); // Using _exit(), since exit() is not async signal safe
signal(sig, SIG_DFL);
kill(getpid(), sig);

This comment has been minimized.

Copy link
@svoj

svoj Dec 6, 2016

Why not raise()?

This comment has been minimized.

Copy link
@vuvova

vuvova Dec 6, 2016

Author Member

FIrst, I didn't know about it.
Second, the systemd manual links to a page that recommends the approach I've used. So, I take it, it has the "official blessing" 😄

#else
return;
#endif
Expand Down

0 comments on commit 76546a0

Please sign in to comment.