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.
This commit is contained in:
Alan Hayward 2019-03-27 10:58:57 +00:00
parent 4c4849b9ed
commit 933aebfae6
2 changed files with 14 additions and 2 deletions

View File

@ -1,3 +1,8 @@
2019-03-27 Alan Hayward <alan.hayward@arm.com>
* gdb.base/interrupt-daemon-attach.c (main): Add alarm and sleep
in child.
2019-03-26 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.python/py-prettyprint.c (struct container) <is_map_p>: New

View File

@ -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;
}