summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
diff options
context:
space:
mode:
authorAlan Hayward <alan.hayward@arm.com>2019-03-27 10:58:57 +0000
committerAlan Hayward <alan.hayward@arm.com>2019-03-27 11:51:15 +0000
commit933aebfae6b1a2b83c3eb958ebf6e43fc7fdaed1 (patch)
tree0bec1bd0d39694a8896d314376bf67cdd40f6ae2 /gdb/testsuite/gdb.base/interrupt-daemon-attach.c
parent4c4849b9ed8c6dd7e1f822e1e395b62059ba7680 (diff)
downloadbinutils-gdb-933aebfae6b1a2b83c3eb958ebf6e43fc7fdaed1.tar.gz
Testsuite: Ensure interrupt-daemon-attach doesn't run forever
Looking at the AArch64 buildbot, I noticed about two dozen old instances of interrupt-daemon-attach taking up a full 100% cpu each. If the test fails then the test binary relies on an alarm to ensure it dies after 60 seconds. As per the Linux man page for alarm: Alarms created by alarm() ... are not inherited by children created via fork. Update the test to add an alarm in the child and also put a sleep in the child loop so it does not constantly consume cpu. Note I haven't managed to re-create why the test failed. This fix will just stop it hanging and consuming cpu when it does. gdb/testsuite/ChangeLog: * gdb.base/interrupt-daemon-attach.c (main): Add alarm and sleep in child.
Diffstat (limited to 'gdb/testsuite/gdb.base/interrupt-daemon-attach.c')
-rw-r--r--gdb/testsuite/gdb.base/interrupt-daemon-attach.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.base/interrupt-daemon-attach.c b/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
index 5dc84438dcb..e8dddf81b4d 100644
--- a/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
+++ b/gdb/testsuite/gdb.base/interrupt-daemon-attach.c
@@ -43,6 +43,7 @@ main ()
break;
default:
+ /* In parent process. */
while (1)
{
marker ();
@@ -50,12 +51,18 @@ main ()
}
}
+ /* In child process. */
+
+ /* Alarms are not inherited by child processes. Set the alarm again to stop
+ the test case running forever. */
+ alarm (60);
+
/* Detach from controlling terminal. */
if (setsid () == (pid_t) -1)
return 1;
- for (;;)
- ;
+ while (1)
+ usleep (1000);
return 0;
}