summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid CARLIER <devnexen@gmail.com>2021-03-30 09:24:25 +0100
committerRobert Bindar <robert@mariadb.org>2021-03-30 19:53:04 +0300
commit99945d77d748470fbb3939be5f7d0e36d24d8097 (patch)
tree08091172ba69fd95e74f46d2cc106521c0d804f8
parentb771ab242baf238463837b9d19eb59d544bff475 (diff)
downloadmariadb-git-99945d77d748470fbb3939be5f7d0e36d24d8097.tar.gz
MDEV-25294 signal handler display coredump on mac
-rw-r--r--sql/signal_handler.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/sql/signal_handler.cc b/sql/signal_handler.cc
index c913a0477d7..61c53e6b6e3 100644
--- a/sql/signal_handler.cc
+++ b/sql/signal_handler.cc
@@ -30,6 +30,11 @@
#define SIGNAL_FMT "signal %d"
#endif
+
+#ifdef __APPLE__
+#include <sys/sysctl.h>
+#endif
+
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
@@ -51,7 +56,7 @@ extern const char *optimizer_switch_names[];
static inline void output_core_info()
{
/* proc is optional on some BSDs so it can't hurt to look */
-#ifdef HAVE_READLINK
+#if defined(HAVE_READLINK) && !defined(__APPLE__)
char buff[PATH_MAX];
ssize_t len;
int fd;
@@ -77,6 +82,13 @@ static inline void output_core_info()
my_close(fd, MYF(0));
}
#endif
+#elif defined(__APPLE__)
+ char buff[PATH_MAX];
+ size_t len = sizeof(buff);
+ if (sysctlbyname("kern.corefile", buff, &len, NULL, 0) == 0)
+ {
+ my_safe_printf_stderr("Core pattern: %.*s\n", (int) len, buff);
+ }
#else
char buff[80];
my_getwd(buff, sizeof(buff), 0);