From d6a03ac4621034acc43a543d158a0cc13629e6c0 Mon Sep 17 00:00:00 2001 From: Sung-jae Park Date: Mon, 17 Feb 2014 10:07:23 +0900 Subject: [PATCH] Update libexec finder Change-Id: Ia2dd512137e2dc9a5167536e199bb23d16dc9f81 --- src/fault.c | 36 +++++++++++++++++++++++++++++++----- src/util.c | 15 ++++++--------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/fault.c b/src/fault.c index 69344ba..eb32235 100644 --- a/src/fault.c +++ b/src/fault.c @@ -50,6 +50,11 @@ static struct info { #endif int marked; int disable_checker; + struct sigaction SEGV_act; + struct sigaction ILL_act; + struct sigaction ALRM_act; + struct sigaction USR1_act; + struct sigaction ABRT_act; } s_info = { .marked = 0, .disable_checker = 0, @@ -125,6 +130,27 @@ static void signal_handler(int signum, siginfo_t *info, void *unused) free(so_fname); free(symbol); + switch (signum) { + case SIGSEGV: + s_info.SEGV_act.sa_sigaction(signum, info, unused); + break; + case SIGALRM: + s_info.ALRM_act.sa_sigaction(signum, info, unused); + break; + case SIGABRT: + s_info.ABRT_act.sa_sigaction(signum, info, unused); + break; + case SIGILL: + s_info.ILL_act.sa_sigaction(signum, info, unused); + break; + case SIGUSR1: + s_info.USR1_act.sa_sigaction(signum, info, unused); + break; + default: + ErrPrint("Unhandled signal\n"); + break; + } + _exit(0); return; } @@ -160,24 +186,24 @@ HAPI int fault_init(void) ErrPrint("Failed to add set: %s\n", strerror(errno)); } - if (sigaction(SIGSEGV, &act, NULL) < 0) { + if (sigaction(SIGSEGV, &act, &s_info.SEGV_act) < 0) { ErrPrint("Failed to install the SEGV handler\n"); } - if (sigaction(SIGABRT, &act, NULL) < 0) { + if (sigaction(SIGABRT, &act, &s_info.ABRT_act) < 0) { ErrPrint("Faield to install the ABRT handler\n"); } - if (sigaction(SIGILL, &act, NULL) < 0) { + if (sigaction(SIGILL, &act, &s_info.ILL_act) < 0) { ErrPrint("Faield to install the ILL handler\n"); } } - if (sigaction(SIGUSR1, &act, NULL) < 0) { + if (sigaction(SIGUSR1, &act, &s_info.USR1_act) < 0) { ErrPrint("Failed to install the USR1 handler\n"); } - if (sigaction(SIGALRM, &act, NULL) < 0) { + if (sigaction(SIGALRM, &act, &s_info.ALRM_act) < 0) { ErrPrint("Failed to install the ALRM handler\n"); } diff --git a/src/util.c b/src/util.c index abae406..9ecbe25 100644 --- a/src/util.c +++ b/src/util.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "critical_log.h" #include "util.h" @@ -108,7 +109,6 @@ HAPI char *util_get_current_module(char **symbol) { int *stack; Dl_info dinfo; - const char *ptr; char *ret; pthread_attr_t attr; unsigned int stack_boundary = 0; @@ -128,18 +128,15 @@ HAPI char *util_get_current_module(char **symbol) continue; } - ptr = util_basename(dinfo.dli_fname); - if (strncmp(ptr, "liblive-", strlen("liblive-"))) { + + ret = livebox_service_pkgname_by_libexec(dinfo.dli_fname); + if (!ret) { DbgPrint("[%d] fname[%s] symbol[%s]\n", i, dinfo.dli_fname, dinfo.dli_sname); - /* - if (!strcmp(ptr, EXEC_NAME)) - return EXEC_NAME; - */ - continue; } - ret = strdup(ptr); + free(ret); + ret = strdup(dinfo.dli_fname); if (symbol) { if (dinfo.dli_sname) { -- 2.7.4