doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

Blame SOURCES/0209-lib-hooklib-make-signal_is_fatal-public.patch

a60cd7
From 27a9ae13ec7b41969eabc88441ad5cca12c26a87 Mon Sep 17 00:00:00 2001
a60cd7
From: Matej Habrnal <mhabrnal@redhat.com>
a60cd7
Date: Mon, 21 Mar 2016 15:38:46 +0100
a60cd7
Subject: [PATCH] lib: hooklib: make signal_is_fatal() public
a60cd7
a60cd7
Related to: rhbz#1277848
a60cd7
a60cd7
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
a60cd7
---
a60cd7
 src/include/hooklib.h |  2 ++
a60cd7
 src/lib/hooklib.c     | 26 ++++++++++++++++++++++++++
a60cd7
 2 files changed, 28 insertions(+)
a60cd7
a60cd7
diff --git a/src/include/hooklib.h b/src/include/hooklib.h
a60cd7
index 4edd4ea..2de0294 100644
a60cd7
--- a/src/include/hooklib.h
a60cd7
+++ b/src/include/hooklib.h
a60cd7
@@ -29,3 +29,5 @@
a60cd7
  stored data, but it's not guaranteed)
a60cd7
  */
a60cd7
 char *problem_data_save(problem_data_t *pd);
a60cd7
+
a60cd7
+int signal_is_fatal(int signal_no, const char **name);
a60cd7
diff --git a/src/lib/hooklib.c b/src/lib/hooklib.c
a60cd7
index 160a011..3e47612 100644
a60cd7
--- a/src/lib/hooklib.c
a60cd7
+++ b/src/lib/hooklib.c
a60cd7
@@ -553,3 +553,29 @@ bool allowed_new_user_problem_entry(uid_t uid, const char *name, const char *val
a60cd7
     error_msg("Only root is permitted to create element '%s' containing '%s'", name, value);
a60cd7
     return false;
a60cd7
 }
a60cd7
+
a60cd7
+int signal_is_fatal(int signal_no, const char **name)
a60cd7
+{
a60cd7
+    const char *signame = NULL;
a60cd7
+    switch (signal_no)
a60cd7
+    {
a60cd7
+        case SIGILL : signame = "ILL" ; break;
a60cd7
+        case SIGFPE : signame = "FPE" ; break;
a60cd7
+        case SIGSEGV: signame = "SEGV"; break;
a60cd7
+        case SIGBUS : signame = "BUS" ; break; //Bus error (bad memory access)
a60cd7
+        case SIGABRT: signame = "ABRT"; break; //usually when abort() was called
a60cd7
+    // We have real-world reports from users who see buggy programs
a60cd7
+    // dying with SIGTRAP, uncommented it too:
a60cd7
+        case SIGTRAP: signame = "TRAP"; break; //Trace/breakpoint trap
a60cd7
+    // These usually aren't caused by bugs:
a60cd7
+      //case SIGQUIT: signame = "QUIT"; break; //Quit from keyboard
a60cd7
+      //case SIGSYS : signame = "SYS" ; break; //Bad argument to routine (SVr4)
a60cd7
+      //case SIGXCPU: signame = "XCPU"; break; //CPU time limit exceeded (4.2BSD)
a60cd7
+      //case SIGXFSZ: signame = "XFSZ"; break; //File size limit exceeded (4.2BSD)
a60cd7
+    }
a60cd7
+
a60cd7
+    if (name != NULL)
a60cd7
+        *name = signame;
a60cd7
+
a60cd7
+   return signame != NULL;
a60cd7
+}
a60cd7
-- 
a60cd7
1.8.3.1
a60cd7