X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=clients%2Fms_sigsegv.c;h=303381f41c1fa0e16b70fc3075c069d0b3d54e80;hb=9351ece659f57ee704b5f0ccfd4b531677ff36f8;hp=33029b42cc35d74b29406ff547c2f65c3926df82;hpb=e42302e08fa4d04cb21eaf7493f5f92b11169c03;p=awesomized%2Flibmemcached diff --git a/clients/ms_sigsegv.c b/clients/ms_sigsegv.c index 33029b42..303381f4 100644 --- a/clients/ms_sigsegv.c +++ b/clients/ms_sigsegv.c @@ -12,7 +12,7 @@ * Author Trond Norbye */ -#include "config.h" +#include "mem_config.h" #include #include @@ -38,29 +38,14 @@ static void ms_signal_segv(int signum, siginfo_t *info, void *ptr) pthread_mutex_lock(&ms_global.quit_mutex); fprintf(stderr, "Segmentation fault occurred.\nStack trace:\n"); +#if 0 pandora_print_callstack(stderr); +#endif fprintf(stderr, "End of stack trace\n"); pthread_mutex_unlock(&ms_global.quit_mutex); abort(); } -/* signal pipe reaches, this function will run */ -static void ms_signal_pipe(int signum, siginfo_t *info, void *ptr) -{ - UNUSED_ARGUMENT(signum); - UNUSED_ARGUMENT(info); - UNUSED_ARGUMENT(ptr); - - pthread_mutex_lock(&ms_global.quit_mutex); - fprintf(stderr, "\tMemslap encountered a server error. Quitting...\n"); - fprintf(stderr, "\tError info: SIGPIPE captured (from write?)\n"); - fprintf(stderr, - "\tProbably a socket I/O error when the server is down.\n"); - pthread_mutex_unlock(&ms_global.quit_mutex); - exit(1); -} /* ms_signal_pipe */ - - /* signal int reaches, this function will run */ static void ms_signal_int(int signum, siginfo_t *info, void *ptr) { @@ -78,7 +63,7 @@ static void ms_signal_int(int signum, siginfo_t *info, void *ptr) /** * redirect signal seg * - * @return if success, return 0, else return -1 + * @return if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_sigsegv(void) { @@ -90,7 +75,7 @@ int ms_setup_sigsegv(void) if (sigaction(SIGSEGV, &action, NULL) < 0) { perror("sigaction"); - return 0; + return EXIT_SUCCESS; } return -1; @@ -100,20 +85,12 @@ int ms_setup_sigsegv(void) /** * redirect signal pipe * - * @return if success, return 0, else return -1 + * @return if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_sigpipe(void) { - struct sigaction action_2; - - memset(&action_2, 0, sizeof(action_2)); - action_2.sa_sigaction= ms_signal_pipe; - action_2.sa_flags= SA_SIGINFO; - if (sigaction(SIGPIPE, &action_2, NULL) < 0) - { - perror("sigaction"); - return 0; - } + /* ignore the SIGPIPE signal */ + signal(SIGPIPE, SIG_IGN); return -1; } /* ms_setup_sigpipe */ @@ -122,7 +99,7 @@ int ms_setup_sigpipe(void) /** * redirect signal int * - * @return if success, return 0, else return -1 + * @return if success, return EXIT_SUCCESS, else return -1 */ int ms_setup_sigint(void) { @@ -134,7 +111,7 @@ int ms_setup_sigint(void) if (sigaction(SIGINT, &action_3, NULL) < 0) { perror("sigaction"); - return 0; + return EXIT_SUCCESS; } return -1;