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

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