Whamcloud - gitweb
debugfs: teach logdump the -n <num_trans> option
[tools/e2fsprogs.git] / e2fsck / sigcatcher.c
index 3b8d582..a9d3b7f 100644 (file)
@@ -132,15 +132,33 @@ static struct str_table sig_table[] = {
 };
 
 static struct str_table generic_code_table[] = {
+#ifdef SI_ASYNCNL
        DEFINE_ENTRY(SI_ASYNCNL)
+#endif
+#ifdef SI_TKILL
        DEFINE_ENTRY(SI_TKILL)
+#endif
+#ifdef SI_SIGIO
        DEFINE_ENTRY(SI_SIGIO)
+#endif
+#ifdef SI_ASYNCIO
        DEFINE_ENTRY(SI_ASYNCIO)
+#endif
+#ifdef SI_MESGQ
        DEFINE_ENTRY(SI_MESGQ)
+#endif
+#ifdef SI_TIMER
        DEFINE_ENTRY(SI_TIMER)
+#endif
+#ifdef SI_QUEUE
        DEFINE_ENTRY(SI_QUEUE)
+#endif
+#ifdef SI_USER
        DEFINE_ENTRY(SI_USER)
+#endif
+#ifdef SI_KERNEL
        DEFINE_ENTRY(SI_KERNEL)
+#endif
        END_TABLE
 };
 
@@ -233,6 +251,7 @@ static struct str_table sigbus_code_table[] = {
        END_TABLE
 };
 
+#if 0 /* should this be hooked in somewhere? */
 static struct str_table sigstrap_code_table[] = {
 #ifdef TRAP_BRKPT
        DEFINE_ENTRY(TRAP_BRKPT)
@@ -242,6 +261,7 @@ static struct str_table sigstrap_code_table[] = {
 #endif
        END_TABLE
 };
+#endif
 
 static struct str_table sigcld_code_table[] = {
 #ifdef CLD_EXITED
@@ -265,6 +285,7 @@ static struct str_table sigcld_code_table[] = {
        END_TABLE
 };
 
+#if 0 /* should this be hooked in somewhere? */
 static struct str_table sigpoll_code_table[] = {
 #ifdef POLL_IN
        DEFINE_ENTRY(POLL_IN)
@@ -286,6 +307,7 @@ static struct str_table sigpoll_code_table[] = {
 #endif
        END_TABLE
 };
+#endif
 
 static const char *lookup_table(int num, struct str_table *table)
 {
@@ -309,10 +331,9 @@ static const char *lookup_table_fallback(int num, struct str_table *table)
        return buf;
 }
 
-static void die_signal_handler(int signum, siginfo_t *siginfo, void *context)
+static void die_signal_handler(int signum, siginfo_t *siginfo,
+                              void *context EXT2FS_ATTR((unused)))
 {
-       void *stack_syms[32];
-       int frames;
        const char *cp;
 
        fprintf(stderr, "Signal (%d) %s ", signum,
@@ -338,7 +359,7 @@ static void die_signal_handler(int signum, siginfo_t *siginfo, void *context)
               fprintf(stderr, "si_code=%s ",
                       lookup_table_fallback(siginfo->si_code,
                                             sigbus_code_table));
-       else if (signum == SIGCLD)
+       else if (signum == SIGCHLD)
               fprintf(stderr, "si_code=%s ",
                       lookup_table_fallback(siginfo->si_code,
                                             sigcld_code_table));
@@ -350,9 +371,14 @@ static void die_signal_handler(int signum, siginfo_t *siginfo, void *context)
               fprintf(stderr, "fault addr=%p", siginfo->si_addr);
        fprintf(stderr, "\n");
 
-#ifdef HAVE_BACKTRACE
-       frames = backtrace(stack_syms, 32);
-       backtrace_symbols_fd(stack_syms, frames, 2);
+#if defined(HAVE_BACKTRACE) && !defined(DISABLE_BACKTRACE)
+       {
+              void *stack_syms[32];
+              int frames;
+
+              frames = backtrace(stack_syms, 32);
+              backtrace_symbols_fd(stack_syms, frames, 2);
+       }
 #endif
        exit(FSCK_ERROR);
 }
@@ -369,6 +395,7 @@ void sigcatcher_setup(void)
        sigaction(SIGILL, &sa, 0);
        sigaction(SIGBUS, &sa, 0);
        sigaction(SIGSEGV, &sa, 0);
+       sigaction(SIGABRT, &sa, 0);
 }