summaryrefslogtreecommitdiff
path: root/debian/patches/kubuntu_raise_after_drkonqi.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/kubuntu_raise_after_drkonqi.patch')
-rw-r--r--debian/patches/kubuntu_raise_after_drkonqi.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/debian/patches/kubuntu_raise_after_drkonqi.patch b/debian/patches/kubuntu_raise_after_drkonqi.patch
new file mode 100644
index 0000000..1722fc1
--- /dev/null
+++ b/debian/patches/kubuntu_raise_after_drkonqi.patch
@@ -0,0 +1,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