Commit 883bda5d authored by unknown's avatar unknown

Merge tulin@bk-internal.mysql.com:/home/bk/mysql-4.1

into poseidon.(none):/home/tomas/mysql-4.1

parents cc6d65b8 0c33b59b
......@@ -41,7 +41,9 @@
extern EventLogger g_eventLogger;
void catchsigs(bool ignore); // for process signal handling
extern "C" void handler(int signo); // for process signal handling
extern "C" void handler_shutdown(int signum); // for process signal handling
extern "C" void handler_error(int signum); // for process signal handling
// Shows system information
void systemInfo(const Configuration & conf,
......@@ -248,71 +250,89 @@ systemInfo(const Configuration & config, const LogLevel & logLevel){
}
static void
handler_register(int signum, sighandler_t handler, bool ignore)
{
if (ignore) {
if(signum != SIGCHLD)
signal(signum, SIG_IGN);
} else
signal(signum, handler);
}
void
catchsigs(bool ignore){
#if ! defined NDB_SOFTOSE && !defined NDB_OSE
#if defined SIGRTMIN
#define MAX_SIG_CATCH SIGRTMIN
#elif defined NSIG
#define MAX_SIG_CATCH NSIG
#else
#error "neither SIGRTMIN or NSIG is defined on this platform, please report bug at bugs.mysql.com"
static const int signals_shutdown[] = {
#ifdef SIGBREAK
SIGBREAK,
#endif
// Makes the main process catch process signals, eg installs a
// handler named "handler". "handler" will then be called is instead
// of the defualt process signal handler)
if(ignore){
for(int i = 1; i < MAX_SIG_CATCH; i++){
if(i != SIGCHLD)
signal(i, SIG_IGN);
}
} else {
for(int i = 1; i < MAX_SIG_CATCH; i++){
signal(i, handler);
}
}
SIGHUP,
SIGINT,
#if defined SIGPWR
SIGPWR,
#elif defined SIGINFO
SIGINFO,
#endif
SIGQUIT,
SIGTERM,
#ifdef SIGTSTP
SIGTSTP,
#endif
SIGTTIN,
SIGTTOU
};
static const int signals_error[] = {
SIGABRT,
SIGALRM,
#ifdef SIGBUS
SIGBUS,
#endif
SIGCHLD,
SIGFPE,
SIGILL,
#ifdef SIGIO
SIGIO,
#endif
#ifdef SIGPOLL
SIGPOLL,
#endif
SIGSEGV,
#ifdef SIGTRAP
SIGTRAP
#endif
};
#endif
static const int signals_ignore[] = {
SIGPIPE
};
for(size_t i = 0; i < sizeof(signals_shutdown)/sizeof(signals_shutdown[0]); i++)
handler_register(signals_shutdown[i], handler_shutdown, ignore);
for(size_t i = 0; i < sizeof(signals_error)/sizeof(signals_error[0]); i++)
handler_register(signals_error[i], handler_error, ignore);
for(size_t i = 0; i < sizeof(signals_ignore)/sizeof(signals_ignore[0]); i++)
handler_register(signals_ignore[i], SIG_IGN, ignore);
}
extern "C"
void
handler(int sig){
switch(sig){
case SIGHUP: /* 1 - Hang up */
case SIGINT: /* 2 - Interrupt */
case SIGQUIT: /* 3 - Quit */
case SIGTERM: /* 15 - Terminate */
#ifdef SIGPWR
case SIGPWR: /* 19 - Power fail */
#endif
#ifdef SIGPOLL
case SIGPOLL: /* 22 */
#endif
case SIGSTOP: /* 23 */
case SIGTSTP: /* 24 */
case SIGTTIN: /* 26 */
case SIGTTOU: /* 27 */
handler_shutdown(int signum){
g_eventLogger.info("Received signal %d. Performing stop.", signum);
globalData.theRestartFlag = perform_stop;
break;
#ifdef SIGWINCH
case SIGWINCH:
#endif
case SIGPIPE:
/**
* Can happen in TCP Transporter
*
* Just ignore
*/
break;
default:
}
extern "C"
void
handler_error(int signum){
g_eventLogger.info("Received signal %d. Running error handler.", signum);
// restart the system
char errorData[40];
snprintf(errorData, 40, "Signal %d received", sig);
snprintf(errorData, 40, "Signal %d received", signum);
ERROR_SET(fatal, 0, errorData, __FILE__);
break;
}
}
......@@ -321,4 +341,3 @@ handler(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