Blame SOURCES/0168-ccpp-Use-Global-PID.patch

a60cd7
From 051448283b05c26ceb5ae561be4b0805d7075b2e Mon Sep 17 00:00:00 2001
a60cd7
From: Jakub Filak <jfilak@redhat.com>
a60cd7
Date: Wed, 9 Sep 2015 14:02:57 +0200
a60cd7
Subject: [PATCH] ccpp: Use Global PID
a60cd7
a60cd7
Related: #1261036
a60cd7
a60cd7
Signed-off-by: Jakub Filak <jfilak@redhat.com>
a60cd7
---
a60cd7
 src/hooks/abrt-hook-ccpp.c          | 20 ++++++++++++--------
a60cd7
 src/hooks/abrt-install-ccpp-hook.in |  4 ++--
a60cd7
 2 files changed, 14 insertions(+), 10 deletions(-)
a60cd7
a60cd7
diff --git a/src/hooks/abrt-hook-ccpp.c b/src/hooks/abrt-hook-ccpp.c
a60cd7
index f5200dc..12b3f118 100644
a60cd7
--- a/src/hooks/abrt-hook-ccpp.c
a60cd7
+++ b/src/hooks/abrt-hook-ccpp.c
a60cd7
@@ -161,12 +161,13 @@ static struct dump_dir *dd;
a60cd7
  * %t - UNIX time of dump
a60cd7
  * %e - executable filename
a60cd7
  * %I - global crash thread tid
a60cd7
+ * %P - global pid
a60cd7
  * %% - output one "%"
a60cd7
  */
a60cd7
 /* Hook must be installed with exactly the same sequence of %c specifiers.
a60cd7
  * Last one, %h, may be omitted (we can find it out).
a60cd7
  */
a60cd7
-static const char percent_specifiers[] = "%scpugteI";
a60cd7
+static const char percent_specifiers[] = "%scpugtePI";
a60cd7
 static char *core_basename = (char*) "core";
a60cd7
 
a60cd7
 static char* get_executable(pid_t pid, int *fd_p)
a60cd7
@@ -688,9 +689,9 @@ int main(int argc, char** argv)
a60cd7
 
a60cd7
     if (argc < 8)
a60cd7
     {
a60cd7
-        /* percent specifier:         %s   %c              %p  %u  %g  %t   %e          %I */
a60cd7
-        /* argv:                  [0] [1]  [2]             [3] [4] [5] [6]  [7]         [8]*/
a60cd7
-        error_msg_and_die("Usage: %s SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME [TID]", argv[0]);
a60cd7
+        /* percent specifier:         %s   %c              %p  %u  %g  %t   %e          %P         %I*/
a60cd7
+        /* argv:                  [0] [1]  [2]             [3] [4] [5] [6]  [7]         [8]        [9]*/
a60cd7
+        error_msg_and_die("Usage: %s SIGNO CORE_SIZE_LIMIT PID UID GID TIME BINARY_NAME GLOBAL_PID [TID]", argv[0]);
a60cd7
     }
a60cd7
 
a60cd7
     /* Not needed on 2.6.30.
a60cd7
@@ -718,9 +719,9 @@ int main(int argc, char** argv)
a60cd7
         ulimit_c = ~((off_t)1 << (sizeof(off_t)*8-1));
a60cd7
     }
a60cd7
     const char *pid_str = argv[3];
a60cd7
-    pid_t pid = xatoi_positive(argv[3]);
a60cd7
+    pid_t local_pid = xatoi_positive(argv[3]);
a60cd7
     uid_t uid = xatoi_positive(argv[4]);
a60cd7
-    if (errno || pid <= 0)
a60cd7
+    if (errno || local_pid <= 0)
a60cd7
     {
a60cd7
         perror_msg_and_die("PID '%s' or limit '%s' is bogus", argv[3], argv[2]);
a60cd7
     }
a60cd7
@@ -733,11 +734,13 @@ int main(int argc, char** argv)
a60cd7
         else
a60cd7
             free(s);
a60cd7
     }
a60cd7
+    const char *global_pid_str = argv[8];
a60cd7
+    pid_t pid = xatoi_positive(argv[8]);
a60cd7
 
a60cd7
     pid_t tid = 0;
a60cd7
-    if (argv[8])
a60cd7
+    if (argv[9])
a60cd7
     {
a60cd7
-        tid = xatoi_positive(argv[8]);
a60cd7
+        tid = xatoi_positive(argv[9]);
a60cd7
     }
a60cd7
 
a60cd7
     char path[PATH_MAX];
a60cd7
@@ -914,6 +917,7 @@ int main(int argc, char** argv)
a60cd7
         dd_save_text(dd, FILENAME_TYPE, "CCpp");
a60cd7
         dd_save_text(dd, FILENAME_EXECUTABLE, executable);
a60cd7
         dd_save_text(dd, FILENAME_PID, pid_str);
a60cd7
+        dd_save_text(dd, /*FILENAME_GLOBAL_PID*/"global_pid", global_pid_str);
a60cd7
         dd_save_text(dd, FILENAME_PROC_PID_STATUS, proc_pid_status);
a60cd7
         if (user_pwd)
a60cd7
             dd_save_text(dd, FILENAME_PWD, user_pwd);
a60cd7
diff --git a/src/hooks/abrt-install-ccpp-hook.in b/src/hooks/abrt-install-ccpp-hook.in
a60cd7
index 65f771f..707c57d 100755
a60cd7
--- a/src/hooks/abrt-install-ccpp-hook.in
a60cd7
+++ b/src/hooks/abrt-install-ccpp-hook.in
a60cd7
@@ -11,9 +11,9 @@ SAVED_PATTERN_DIR="@VAR_RUN@/abrt"
a60cd7
 SAVED_PATTERN_FILE="@VAR_RUN@/abrt/saved_core_pattern"
a60cd7
 HOOK_BIN="@libexecdir@/abrt-hook-ccpp"
a60cd7
 # Must match percent_specifiers[] order in abrt-hook-ccpp.c:
a60cd7
-PATTERN="|$HOOK_BIN %s %c %p %u %g %t %e %I"
a60cd7
+PATTERN="|$HOOK_BIN %s %c %p %u %g %t %e %P %I"
a60cd7
 # Same, but with bogus "executable name" parameter
a60cd7
-PATTERN1="|$HOOK_BIN %s %c %p %u %g %t e %I"
a60cd7
+PATTERN1="|$HOOK_BIN %s %c %p %u %g %t e %P %I"
a60cd7
 
a60cd7
 # core_pipe_limit specifies how many dump_helpers can run at the same time
a60cd7
 # 0 - means unlimited, but it's not guaranteed that /proc/<pid> of crashing
a60cd7
-- 
a60cd7
2.4.3
a60cd7