From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed] [gdb/testsuite] Set alarm in fork child in a few test-cases
Date: Sat, 21 Nov 2026 12:01:00 +0100 [thread overview]
Message-ID: <20261121110100.3066169-1-tdevries@suse.de> (raw)
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
reply other threads:[~2026-11-21 11:01 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261121110100.3066169-1-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox