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

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