This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug testsuite/23269] fork-running-state hangs make check


https://sourceware.org/bugzilla/show_bug.cgi?id=23269

Tom de Vries <vries at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |testsuite

--- Comment #3 from Tom de Vries <vries at gcc dot gnu.org> ---
The hanging process is the child process that gdb detaches from.

There's an alarm set in main before the fork, but:
...
$ man alarm
   ...
NOTES
       Alarms created by alarm() are preserved across execve(2) and are not
inherited by children created via fork(2).
...
So, AFAIU, once the parent is killed, there's no alarm to terminate the child.

By moving the setting of the alarm into the fork_main/fork_child functions, we
make sure that the alarm also triggers for the child:
...
diff --git a/gdb/testsuite/gdb.base/fork-running-state.c
b/gdb/testsuite/gdb.base/fork-running-state.c
index 8ea4739609..65ca942ea0 100644
--- a/gdb/testsuite/gdb.base/fork-running-state.c
+++ b/gdb/testsuite/gdb.base/fork-running-state.c
@@ -27,6 +27,9 @@ int save_parent;
 static int
 fork_child (void)
 {
+  /* Don't run forever.  */
+  alarm (180);
+
   while (1)
     pause ();

@@ -38,6 +41,9 @@ fork_child (void)
 static int
 fork_parent (void)
 {
+  /* Don't run forever.  */
+  alarm (180);
+
   while (1)
     pause ();

@@ -51,9 +57,6 @@ main (void)

   save_parent = getpid ();

-  /* Don't run forever.  */
-  alarm (180);
-
   /* The parent and child should basically run forever without
      tripping on any debug event.  We want to check that GDB updates
      the parent and child running states correctly right after the
...

This works for the minimal fork-running-state.exp,, and for the original
fork-running-state.exp,: after 180 seconds, there are no sleeping processes
anymore.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]