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

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