From: Adam Dickmeiss Date: Thu, 20 Nov 2014 13:36:58 +0000 (+0100) Subject: backtrace: wait longer time before giving up on gdb X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=refs%2Fheads%2Fyaz-787;p=yaz-moved-to-github.git backtrace: wait longer time before giving up on gdb Testing on Raspberry Pi of course. --- 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(); }