Package: kde4libs / 4:4.14.26-2

kubuntu_raise_after_drkonqi.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
From: Debian/Kubuntu Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Date: Wed, 13 Apr 2016 16:40:35 +0200
Subject: kubuntu_raise_after_drkonqi

===================================================================
---
 kdeui/util/kcrash.cpp | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/kdeui/util/kcrash.cpp b/kdeui/util/kcrash.cpp
index cf12933ff3..851764b581 100644
--- a/kdeui/util/kcrash.cpp
+++ b/kdeui/util/kcrash.cpp
@@ -223,6 +223,39 @@ bool KCrash::isDrKonqiEnabled()
     return s_launchDrKonqi;
 }
 
+/**
+ * \brief possiblyRaiseForApport raises() signal to native handler.
+ * \param sig signal that was handled by KCrash
+ * \return Does not return when raised for Apport
+ */
+static void possiblyRaiseForApport(int sig)
+{
+#define BUFSIZE 256
+    char buf[BUFSIZE];
+    const size_t bufSize = readlink("/proc/self/exe", buf, BUFSIZE);
+    buf[bufSize] = '\0'; // readlink doesn't NUL terminate.
+    for (char *c = buf; *c != '\0'; ++c){
+        if (*c == '/') {
+            *c = '_';
+        }
+    }
+
+    const uid_t uid = getuid();
+    char filePath[BUFSIZE];
+    sprintf(filePath, "/var/crash/%s.%d.drkonqi-accept", buf, uid);
+
+    if (access(filePath, F_OK) != -1) {
+        // Apport needs to get a core dump to enable automatic metrics submission.
+        // So instead of exit we are raising into the native signal handler.
+        fprintf(stderr, "Re-raising signal for Apport handling.\n");
+        KCrash::setCrashHandler(0);
+        raise(sig);
+    }
+    fprintf(stderr, "Not forwarding the crash to Apport.\n");
+    // Automatic report not allowed. No-op.
+#undef BUFSIZE
+}
+
 void
 KCrash::setCrashHandler (HandlerType handler)
 {
@@ -446,6 +479,7 @@ KCrash::defaultCrashHandler (int sig)
       fprintf(stderr, "Unable to start Dr. Konqi\n");
     }
 
+    possiblyRaiseForApport(sig);
     _exit(255);
 }
 
@@ -567,7 +601,8 @@ static bool startProcessInternal(int argc, const char *argv[], bool waitAndExit,
                 sleep(1);
             }
         }
-        _exit(253);
+        // Do not exit here as we need to handle end of execution inside KCrash.
+        // _exit(253);
     }
 
     return (pid > 0); //return true on success