* [pushed] [gdb/testsuite] Set alarm in fork child in a few test-cases
@ 2026-11-21 11:01 Tom de Vries
0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2026-11-21 11:01 UTC (permalink / raw)
To: gdb-patches
I ran the testsuite on cygwin, and noticed a lingering process
attach-non-pgrp-leader.
The test-case creates two processes, a fork parent and child, and it's the
child process that is lingering.
The parent process is cleaned up by either:
- kill_wait_spawned_process, or
- an alarm
The alarm is set at the start of main, but child processes don't inherit the
alarm.
Fix the missing alarm by setting an alarm in the child process as well.
Likewise in a few other test-cases.
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33061
---
gdb/testsuite/gdb.base/attach-non-pgrp-leader.c | 10 ++++++++++
gdb/testsuite/gdb.base/interrupt-daemon.c | 5 +++++
gdb/testsuite/gdb.threads/fork-thread-pending.c | 6 ++++++
3 files changed, 21 insertions(+)
diff --git a/gdb/testsuite/gdb.base/attach-non-pgrp-leader.c b/gdb/testsuite/gdb.base/attach-non-pgrp-leader.c
index 33a92167051..72ed285b158 100644
--- a/gdb/testsuite/gdb.base/attach-non-pgrp-leader.c
+++ b/gdb/testsuite/gdb.base/attach-non-pgrp-leader.c
@@ -34,6 +34,16 @@ main ()
child_pid = fork ();
if (child_pid == -1)
return 1;
+ else if (child_pid == 0)
+ {
+ /* Child. */
+
+ /* Alarms are not inherited by child processes. Set the alarm again to
+ stop the process running forever. */
+ alarm (60);
+ }
+
+ /* Parent and child. */
while (1)
{
diff --git a/gdb/testsuite/gdb.base/interrupt-daemon.c b/gdb/testsuite/gdb.base/interrupt-daemon.c
index 4931db29802..240a6661a3e 100644
--- a/gdb/testsuite/gdb.base/interrupt-daemon.c
+++ b/gdb/testsuite/gdb.base/interrupt-daemon.c
@@ -57,6 +57,11 @@ main ()
return 0;
/* In grandchild. */
+
+ /* Alarms are not inherited by child processes. Set the alarm again to
+ stop the process running forever. */
+ alarm (60);
+
daemon_main ();
while (1)
diff --git a/gdb/testsuite/gdb.threads/fork-thread-pending.c b/gdb/testsuite/gdb.threads/fork-thread-pending.c
index 91de8eac741..99f2e29755b 100644
--- a/gdb/testsuite/gdb.threads/fork-thread-pending.c
+++ b/gdb/testsuite/gdb.threads/fork-thread-pending.c
@@ -75,6 +75,12 @@ thread_forker (void *arg)
done = 1;
break;
case 0:
+ /* Child. */
+
+ /* Alarms are not inherited by child processes. Set the alarm again to
+ stop the process running forever. */
+ alarm (600);
+
i = pthread_create (&thread, NULL, start, NULL);
assert (i == 0);
i = pthread_join (thread, NULL);
base-commit: de6d0c54d749a19e7422bf04b9b8f924d5e35bd5
--
2.51.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-21 11:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-21 11:01 [pushed] [gdb/testsuite] Set alarm in fork child in a few test-cases Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox