a8767b3
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
f524ac5
From: Fedora GDB patches <invalid@email.com>
f524ac5
Date: Fri, 27 Oct 2017 21:07:50 +0200
f524ac5
Subject: gdb-6.5-bz243845-stale-testing-zombie-test.patch
f524ac5
f637971
;; Test leftover zombie process (BZ 243845).
f637971
;;=fedoratest
f524ac5
f637971
diff --git a/gdb/testsuite/gdb.base/tracefork-zombie.exp b/gdb/testsuite/gdb.base/tracefork-zombie.exp
f637971
new file mode 100644
f637971
--- /dev/null
f637971
+++ b/gdb/testsuite/gdb.base/tracefork-zombie.exp
dd46ae6
@@ -0,0 +1,75 @@
e3c8b47
+# Copyright 2007 Free Software Foundation, Inc.
e3c8b47
+
e3c8b47
+# This program is free software; you can redistribute it and/or modify
e3c8b47
+# it under the terms of the GNU General Public License as published by
e3c8b47
+# the Free Software Foundation; either version 2 of the License, or
e3c8b47
+# (at your option) any later version.
e3c8b47
+# 
e3c8b47
+# This program is distributed in the hope that it will be useful,
e3c8b47
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
e3c8b47
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
e3c8b47
+# GNU General Public License for more details.
e3c8b47
+# 
e3c8b47
+# You should have received a copy of the GNU General Public License
e3c8b47
+# along with this program; if not, write to the Free Software
e3c8b47
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
e3c8b47
+
e3c8b47
+# are we on a target board
e3c8b47
+if [is_remote target] then {
e3c8b47
+    return 0
e3c8b47
+}
e3c8b47
+
e3c8b47
+# Start the program running and then wait for a bit, to be sure
e3c8b47
+# that it can be attached to.
e3c8b47
+
e3c8b47
+gdb_exit
e3c8b47
+gdb_start
e3c8b47
+gdb_load sleep
e3c8b47
+
e3c8b47
+set gdb_pid [exp_pid -i [board_info host fileid]]
e3c8b47
+set test "identified the child GDB"
e3c8b47
+if {$gdb_pid != "" && $gdb_pid > 0} {
e3c8b47
+    pass $test
e3c8b47
+    verbose -log "Child GDB PID $gdb_pid"
e3c8b47
+} else {
e3c8b47
+    fail $test
e3c8b47
+}
e3c8b47
+
e3c8b47
+set testpid [eval exec sleep 10 &]
e3c8b47
+exec sleep 2
e3c8b47
+
e3c8b47
+set test "attach"
e3c8b47
+gdb_test_multiple "attach $testpid" "$test" {
e3c8b47
+    -re "Attaching to program.*`?.*'?, process $testpid..*$gdb_prompt $" {
e3c8b47
+	pass "$test"
e3c8b47
+    }
e3c8b47
+    -re "Attaching to program.*`?.*\.exe'?, process $testpid.*\[Switching to thread $testpid\..*\].*$gdb_prompt $" {
e3c8b47
+	# Response expected on Cygwin
e3c8b47
+	pass "$test"
e3c8b47
+    }
e3c8b47
+}
e3c8b47
+
e3c8b47
+# Some time to let GDB spawn its testing child.
e3c8b47
+exec sleep 2
e3c8b47
+
e3c8b47
+set found none
e3c8b47
+foreach procpid [glob -directory /proc -type d {[0-9]*}] {
e3c8b47
+    if {[catch {open $procpid/status} statusfi]} {
e3c8b47
+	continue
e3c8b47
+    }
e3c8b47
+    set status [read $statusfi]
e3c8b47
+    close $statusfi
e3c8b47
+    if {1
e3c8b47
+         && [regexp -line {^Name:\tgdb$} $status]
e3c8b47
+         && [regexp -line {^PPid:\t1$} $status]
e3c8b47
+         && [regexp -line "^TracerPid:\t$gdb_pid$" $status]} {
e3c8b47
+	set found $procpid
e3c8b47
+	verbose -log "Found linux_test_for_tracefork zombie PID $procpid"
e3c8b47
+    }
e3c8b47
+}
e3c8b47
+set test "linux_test_for_tracefork leaves no zombie"
e3c8b47
+if {$found eq {none}} {
e3c8b47
+    pass $test
e3c8b47
+} else {
e3c8b47
+    fail $test
e3c8b47
+}