From d84d146d9d09c97a6a068f76a669dbd2f405fe98 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 27 Sep 2019 08:48:27 +1000 Subject: MDEV-19508: signal handler SI_KERNEL not defined on Solaris/AIX Solaris and AIX doesn't have a SI_KERNEL code for its siginfo code structure. But they define sigwaitinfo. For these we can use SI_USER and values <= aren't kernel. SI_USER is defined on AIX (since AIX 6.1 at least) as: /usr/include/sys/signal.h #define SI_USER 0 /* signal sent by another process with kill */ So its effectively not kernel. Linux also uses SI_USER as its highest user code. FreeBSD-12.1 available defines are: #if __POSIX_VISIBLE || __XSI_VISIBLE #define SI_NOINFO 0 /* No signal info besides si_signo. */ #define SI_USER 0x10001 /* Signal sent by kill(). */ #define SI_QUEUE 0x10002 /* Signal sent by the sigqueue(). */ #define SI_TIMER 0x10003 /* Signal generated by expiration of */ /* a timer set by timer_settime(). */ #define SI_ASYNCIO 0x10004 /* Signal generated by completion of */ /* an asynchronous I/O request.*/ #define SI_MESGQ 0x10005 /* Signal generated by arrival of a */ /* message on an empty message queue. */ #define SI_KERNEL 0x10006 #define SI_LWP 0x10007 /* Signal sent by thr_kill */ #endif Original commit 07e9b1389857 showed an explicit desire to catch user signals aka kill(SI_USER). So for FreeBSD != SI_KERNEL is too broad and should be <= SI_USER too. ref: https://docs.oracle.com/cd/E36784_01/html/E36873/siginfo.h-3head.html ref: https://github.com/omniosorg/illumos-omnios/blob/master/usr/src/uts/common/sys/siginfo.h#L130 --- include/my_pthread.h | 4 +++- sql/mysqld.cc | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/my_pthread.h b/include/my_pthread.h index 81dd63ee331..878d88414df 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -197,7 +197,9 @@ static inline int my_sigwait(sigset_t *set, int *sig, int *code) *code= siginfo.si_code; return *sig < 0 ? errno : 0; #else -#define SI_KERNEL 128 +#ifndef SI_USER +#define SI_USER 0 +#endif *code= 0; return sigwait(set, sig); #endif diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 26012f317f9..f96eaa4176f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3288,7 +3288,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused))) } break; case SIGHUP: - if (!abort_loop && origin != SI_KERNEL) + if (!abort_loop && origin <= SI_USER) { int not_used; mysql_print_status(); // Print some debug info -- cgit v1.2.1