arrfab / rpms / abrt

Forked from rpms/abrt 5 years ago
Clone

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

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