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
|
Index: kde4libs/kdeui/util/kcrash.cpp
===================================================================
--- kde4libs.orig/kdeui/util/kcrash.cpp 2015-02-16 10:23:28.265819116 +0100
+++ kde4libs/kdeui/util/kcrash.cpp 2015-02-16 10:23:28.265819116 +0100
@@ -223,6 +223,39 @@
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 @@
fprintf(stderr, "Unable to start Dr. Konqi\n");
}
+ possiblyRaiseForApport(sig);
_exit(255);
}
@@ -567,7 +601,8 @@
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
|