--- /dev/null
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2020-2021 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <unistd.h>
+
+static volatile int release_parent = 0;
+
+static void
+break_parent (void)
+{
+}
+
+int
+main (void)
+{
+ if (vfork () != 0)
+ {
+ while (!release_parent);
+ break_parent ();
+ }
+ else
+ _exit (0);
+
+ return 0;
+}
--- /dev/null
+# Copyright 2020-2021 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# This serves as a template for writing new test cases. Replace this with
+# a description of what this test case tests.
+
+standard_testfile
+
+if { [build_executable "failed to prepare" \
+ ${testfile} ${srcfile}] } {
+ return
+}
+
+proc do_test { method } {
+ clean_restart $::binfile
+
+ gdb_test_no_output "set detach-on-fork off"
+
+ if { ![runto_main] } {
+ return
+ }
+
+ gdb_test "break break_parent"
+
+ gdb_test "continue" \
+ "Can not resume the parent process over vfork .*" \
+ "continue to vfork"
+
+ # Try to continue again from there, expecting the same message. It takes a
+ # different code path in GDB.
+ gdb_test "continue" \
+ "Can not resume the parent process over vfork .*" \
+ "try to continue from vfork"
+
+ if { $method == "detach-on-fork" } {
+ gdb_test "set detach-on-fork on"
+ } elseif { $method == "schedule-multiple" } {
+ gdb_test "set schedule-multiple on"
+ gdb_test "continue" "$::inferior_exited_re normally.*" \
+ "continue to end of inferior 2"
+ gdb_test "inferior 1" ".*Switching to inferior 1.*"
+ } else {
+ error "invalid method: $method"
+ }
+
+ gdb_test "p release_parent = 1" " = 1"
+ gdb_test "continue" "Breakpoint $::decimal, break_parent .*" \
+ "continue to break_parent"
+}
+
+foreach_with_prefix method {detach-on-fork schedule-multiple} {
+ do_test $method
+}