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

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