GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
testsuite

Testsuite: Parent processes now wait for forked children.

GCC testsuite fixes race conditions in profiling and gcov tests by ensuring parent processes wait for forked children.

Two GCC testsuite programs, time-profiler-2.c and gcov-pr86536.c, now correctly wait for their forked child processes to complete. Previously, the parent process exited without waiting, which could lead to the child being killed by a SIGHUP signal before writing profile data. This caused failures in time profiling and incorrect line counts in gcov, particularly under simulators or specific pty configurations.

In Details

This commit addresses a race condition in two GCC testsuite programs: gcc.dg/tree-prof/time-profiler-2.c and gcc.misc-tests/gcov-pr86536.c. Both tests use fork(). The parent process was exiting prematurely without wait()ing for the child. When run under DejaGnu with a pseudo-terminal (pty), the hangup signal (SIGHUP) sent to the parent process upon session exit would kill the child. This prevented the child from completing its tasks (e.g., writing profile data), leading to test failures where the time profiler missed calls or gcov reported incorrect counts.

For Context
fork
A system call that creates a new process, which is a copy of the calling process. The new process is called the child, and the calling process is called the parent.
wait
A system call that allows a parent process to pause its execution until one of its child processes terminates. It retrieves the exit status of the terminated child.
SIGHUP
A signal sent to a process when its controlling terminal is closed or disconnected. It typically indicates that the controlling session has ended.
pty
Pseudo-terminal. A pair of devices that emulate a physical terminal, often used for inter-process communication or remote access.
DejaGnu
A testing framework that provides a way to test other programs. It handles test execution, result reporting, and setup/cleanup.
gcov
A command-line tool that collects code coverage information from compiled C and C++ programs.
Filed Under: testsuiteforkgcovprofiling