arrfab / rpms / abrt

Forked from rpms/abrt 5 years ago
Clone

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

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