core_handler(int signo #ifdef SA_SIGINFO , siginfo_t *siginfo, void *context #endif ) { /* make sure we don't hang in here. default for SIGALRM is terminate. * - if we're in backtrace for more than a second, abort. */ struct sigaction sa_default = {.sa_handler = SIG_DFL}; sigaction(SIGALRM, &sa_default, NULL); sigset_t sigset; sigemptyset(&sigset); sigaddset(&sigset, SIGALRM); sigprocmask(SIG_UNBLOCK, &sigset, NULL); alarm(1); zlog_signal(signo, "aborting..." #ifdef SA_SIGINFO , siginfo, program_counter(context) #endif ); /* dump memory stats on core */ log_memstats(stderr, "core_handler"); abort(); }
zerror (const char *fname, int type, size_t size) { zlog_err ("%s : can't allocate memory for `%s' size %d: %s\n", fname, lookup (mstr, type), (int) size, safe_strerror(errno)); log_memstats(LOG_WARNING); /* N.B. It might be preferable to call zlog_backtrace_sigsafe here, since that function should definitely be safe in an OOM condition. But unfortunately zlog_backtrace_sigsafe does not support syslog logging at this time... */ zlog_backtrace(LOG_WARNING); abort(); }