From 01de316fc2eac29cace25b8c9e773b1e4fd6f82c Mon Sep 17 00:00:00 2001 From: "monty@narttu.mysql.fi" <> Date: Mon, 26 May 2003 17:24:16 +0300 Subject: [PATCH] Fixed problem with 'kill pid-of-mysqld' on Mac OS X --- sql/mysqld.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 4e88a6fcb32..f729dcfd17a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1346,6 +1346,7 @@ information that should help you find out what is causing the crash\n"); static void init_signals(void) { sigset_t set; + struct sigaction sa; DBUG_ENTER("init_signals"); sigset(THR_KILL_SIGNAL,end_thread_signal); @@ -1353,7 +1354,6 @@ static void init_signals(void) if (!(test_flags & TEST_NO_STACKTRACE) || (test_flags & TEST_CORE_ON_SIGNAL)) { - struct sigaction sa; sa.sa_flags = SA_RESETHAND | SA_NODEFER; sigemptyset(&sa.sa_mask); sigprocmask(SIG_SETMASK,&sa.sa_mask,NULL); @@ -1378,15 +1378,22 @@ static void init_signals(void) sigaddset(&set,SIGQUIT); sigaddset(&set,SIGTERM); sigaddset(&set,SIGHUP); - sigset(SIGTERM,print_signal_warning); // If it's blocked by parent - signal(SIGHUP,print_signal_warning); // If it's blocked by parent + + /* Fix signals if blocked by parents (can happen on Mac OS X) */ + sa.sa_flags = 0; + sa.sa_handler = print_signal_warning; + sigaction(SIGTERM, &sa, (struct sigaction*) 0); + sa.sa_flags = 0; + sa.sa_handler = print_signal_warning; + sigaction(SIGHUP, &sa, (struct sigaction*) 0); #ifdef SIGTSTP sigaddset(&set,SIGTSTP); #endif sigaddset(&set,THR_SERVER_ALARM); sigdelset(&set,THR_KILL_SIGNAL); // May be SIGINT sigdelset(&set,THR_CLIENT_ALARM); // For alarms - (void) pthread_sigmask(SIG_SETMASK,&set,NULL); + sigprocmask(SIG_SETMASK,&set,NULL); + pthread_sigmask(SIG_SETMASK,&set,NULL); DBUG_VOID_RETURN; }