e3c8b47
diff -u -ruNp gdb-6.3-unpatched/gdb/testsuite/gdb.base/tracefork-zombie.exp gdb-6.3/gdb/testsuite/gdb.base/tracefork-zombie.exp
e3c8b47
--- gdb-6.3-unpatched/gdb/testsuite/gdb.base/tracefork-zombie.exp	1969-12-31 19:00:00.000000000 -0500
e3c8b47
+++ gdb-6.3/gdb/testsuite/gdb.base/tracefork-zombie.exp	2007-07-31 13:04:12.000000000 -0400
e3c8b47
@@ -0,0 +1,82 @@
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
+if $tracelevel then {
e3c8b47
+    strace $tracelevel
e3c8b47
+}
e3c8b47
+
e3c8b47
+set prms_id 0
e3c8b47
+set bug_id 0
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
+}