summaryrefslogtreecommitdiff
path: root/include/my_pthread.h
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2018-12-07 13:05:34 +0100
committerSergei Golubchik <serg@mariadb.org>2018-12-12 00:31:04 +0100
commit07e9b1389857a8c0fee1dfda443ae257982fd2c9 (patch)
tree879bfa4336527aabf9d1ce259a898df2a42fd1da /include/my_pthread.h
parent97dbb3562b0b230e01605f00e441e8a70d10b6a8 (diff)
downloadmariadb-git-07e9b1389857a8c0fee1dfda443ae257982fd2c9.tar.gz
mysqld: ignore SIGHUP sent by the kernel
SIGHUP causes debug info in the error log and reload of logs/privileges/tables/etc. The server should only do it when a user intentionally sends SUGHUP, not when a parent terminal gets disconnected or something. In particular, not ignoring kernel SIGHUP causes FLUSH PRIVILEGES at some random point during non-systemd Debian upgrades (Debian restarts mysqld, debian-start script runs mysql_upgrade in the background, postinit script ends and kernel sends SIGHUP to all background processes it has started). And during mysql_upgrade privilege tables aren't necessarily ready to be reloaded.
Diffstat (limited to 'include/my_pthread.h')
-rw-r--r--include/my_pthread.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 2712c7d8ffd..843701ccab9 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -189,7 +189,19 @@ extern int my_pthread_create_detached;
int sigwait(sigset_t *set, int *sig);
#endif
-#define my_sigwait(A,B) sigwait((A),(B))
+static inline int my_sigwait(sigset_t *set, int *sig, int *code)
+{
+#ifdef HAVE_SIGWAITINFO
+ siginfo_t siginfo;
+ *sig= sigwaitinfo(set, &siginfo);
+ *code= siginfo.si_code;
+ return *sig < 0 ? errno : 0;
+#else
+#define SI_KERNEL 128
+ *code= 0;
+ return sigwait(set, sig);
+#endif
+}
#if defined(HAVE_SIGTHREADMASK) && !defined(HAVE_PTHREAD_SIGMASK)
#define pthread_sigmask(A,B,C) sigthreadmask((A),(B),(C))