https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111298
--- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Igor Shevlyakov <[email protected]>: https://gcc.gnu.org/g:56a683e3987cb8d0d33b4be9e8a83307a4cb8ba4 commit r17-5715-g56a683e3987cb8d0d33b4be9e8a83307a4cb8ba4 Author: Michael Morrell <[email protected]> Date: Tue Oct 27 13:17:38 2026 -0700 testsuite: Wait for forked children in time-profiler-2.c and gcov-pr86536.c [PR111298] gcc.dg/tree-prof/time-profiler-2.c and gcc.misc-tests/gcov-pr86536.c call fork, and the parent returns from main without waiting for the child. DejaGnu runs the test program on a pty, as the session leader. When the parent exits, the kernel hangs up the pty and sends SIGHUP to its foreground process group, so a child that is still running is killed before it writes its profile counts. time-profiler-2.c then misses the child's call to bar, and its tp_first_run checks fail; gcov-pr86536.c reports a count of 1 instead of 2 for the lines after the fork. Natively the child usually finishes first, so this rarely shows. Under a simulator it often does not: with user-mode QEMU both tests fail on every run, and with another simulator time-profiler-2.c fails intermittently. Running the same programs on a pty with SIGHUP ignored, or without a pty, always keeps the child's counts. Make the parent wait for the child in both tests. In gcov-pr86536.c the call goes on the blank line before the first count(2) line, so no annotated line moves: gcov.exp names its checks by line number, and the expected counts are unchanged. Assisted-by: Claude Opus 5.5 PR testsuite/111298 gcc/testsuite/ChangeLog: * gcc.dg/tree-prof/time-profiler-2.c: Require fork. Include <sys/wait.h>. (main): Wait for the child process. * gcc.misc-tests/gcov-pr86536.c (main): Likewise. Signed-off-by: Michael Morrell <[email protected]>
