From 79a5159b46cbd89a9e6702c0e290e2043d2361fe Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Thu, 20 Nov 2014 14:36:58 +0100 Subject: [PATCH] backtrace: wait longer time before giving up on gdb Testing on Raspberry Pi of course. --- src/backtrace.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/backtrace.c b/src/backtrace.c index 23c1edc..567e55f 100644 --- a/src/backtrace.c +++ b/src/backtrace.c @@ -49,12 +49,8 @@ static void yaz_invoke_backtrace(char *buf, int buf_sz) int fds[2]; void *backtrace_info[BACKTRACE_SZ]; int sz = BACKTRACE_SZ; - int left = buf_sz - strlen(buf); - yaz_snprintf(buf + strlen(buf), left, "backtrace: PID=" NMEM_INT_PRINTF - "\n", (nmem_int_t) getpid()); write(fd, buf, strlen(buf)); - sz = backtrace(backtrace_info, sz); backtrace_symbols_fd(backtrace_info, sz, fd); @@ -112,14 +108,15 @@ static void yaz_invoke_backtrace(char *buf, int buf_sz) pid_t s = waitpid(pid, &status, WNOHANG); if (s != 0) break; - if (sec == 2) + if (sec == 9) kill(pid, SIGTERM); - if (sec == 3) + if (sec == 10) kill(pid, SIGKILL); - if (sec == 4) + if (sec == 11) break; + if (sec > 3) + write(fds[1], "quit\n", 5); sleep(1); - write(fds[1], "quit\n", 5); sec++; } close(fds[1]); @@ -135,25 +132,27 @@ static void yaz_panic_sig_handler(int sig) char buf[512]; signal(SIGABRT, SIG_DFL); - strcpy(buf, "\nyaz_panic_sig_handlet received "); + strcpy(buf, "\nYAZ panic received "); switch (sig) { case SIGSEGV: - strcat(buf, "SIGSEGV\n"); + strcat(buf, "SIGSEGV"); break; case SIGABRT: - strcat(buf, "SIGABRT\n"); + strcat(buf, "SIGABRT"); break; case SIGFPE: - strcat(buf, "SIGFPE\n"); + strcat(buf, "SIGFPE"); break; case SIGBUS: - strcat(buf, "SIGBUS\n"); + strcat(buf, "SIGBUS"); break; default: - yaz_snprintf(buf + strlen(buf), sizeof buf, "signo=%d\n", sig); + yaz_snprintf(buf + strlen(buf), sizeof buf, "signo=%d", sig); break; } + yaz_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf) - 1, + " PID=" NMEM_INT_PRINTF "\n", (nmem_int_t) getpid()); yaz_invoke_backtrace(buf, sizeof buf); abort(); } -- 1.7.10.4