arrfab / rpms / abrt

Forked from rpms/abrt 5 years ago
Clone

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

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