Blame SOURCES/gdb-rhbz1493675-gcore-sigkilled-process.patch

8f6b9e
https://bugzilla.redhat.com/show_bug.cgi?id=1493675
8f6b9e
8f6b9e
diff -dup -rup gdb-7.6.1-orig/gdb/gcore.c gdb-7.6.1/gdb/gcore.c
8f6b9e
--- gdb-7.6.1-orig/gdb/gcore.c	2017-10-20 22:28:50.990391003 +0200
8f6b9e
+++ gdb-7.6.1/gdb/gcore.c	2017-10-20 22:29:26.797710799 +0200
8f6b9e
@@ -111,8 +111,8 @@ do_bfd_delete_cleanup (void *arg)
8f6b9e
   bfd *obfd = arg;
8f6b9e
   const char *filename = obfd->filename;
8f6b9e
 
8f6b9e
-  gdb_bfd_unref (arg);
8f6b9e
   unlink (filename);
8f6b9e
+  gdb_bfd_unref (arg);
8f6b9e
 }
8f6b9e
 
8f6b9e
 /* gcore_command -- implements the 'gcore' command.
8f6b9e
--- ./gdb/inf-ptrace.c	2017-09-28 20:14:05.802344770 +0200
8f6b9e
+++ ./gdb/inf-ptrace.c	2017-09-28 22:04:30.417779859 +0200
8f6b9e
@@ -280,6 +280,7 @@ inf_ptrace_detach (struct target_ops *op
8f6b9e
 {
8f6b9e
   pid_t pid = ptid_get_pid (inferior_ptid);
8f6b9e
   int sig = 0;
8f6b9e
+  int saved_errno;
8f6b9e
 
8f6b9e
   if (from_tty)
8f6b9e
     {
8f6b9e
@@ -300,8 +301,7 @@ inf_ptrace_detach (struct target_ops *op
8f6b9e
      started the process ourselves.  */
8f6b9e
   errno = 0;
8f6b9e
   ptrace (PT_DETACH, pid, (PTRACE_TYPE_ARG3)1, sig);
8f6b9e
-  if (errno != 0)
8f6b9e
-    perror_with_name (("ptrace"));
8f6b9e
+saved_errno = errno;
8f6b9e
 #else
8f6b9e
   error (_("This system does not support detaching from a process"));
8f6b9e
 #endif
8f6b9e
@@ -311,6 +311,11 @@ inf_ptrace_detach (struct target_ops *op
8f6b9e
 
8f6b9e
   if (!have_inferiors ())
8f6b9e
     unpush_target (ops);
8f6b9e
+
8f6b9e
+if (saved_errno != 0) {
8f6b9e
+  errno = saved_errno;
8f6b9e
+  perror_with_name (("ptrace"));
8f6b9e
+}
8f6b9e
 }
8f6b9e
 
8f6b9e
 /* Kill the inferior.  */