Skip to content

Fix SIGTERM handling in collect_coverage.sh for test timeouts#29565

Open
olbapmar wants to merge 1 commit into
bazelbuild:masterfrom
olbapmar:coverage-sigterm-handling
Open

Fix SIGTERM handling in collect_coverage.sh for test timeouts#29565
olbapmar wants to merge 1 commit into
bazelbuild:masterfrom
olbapmar:coverage-sigterm-handling

Conversation

@olbapmar
Copy link
Copy Markdown

Description

Bash does not run trap handlers while a foreground process is executing.

When Bazel sends SIGTERM on test timeout, the coverage wrapper dies immediately, meaning that the test process has no opportunity to shut down gracefully or clean up resources.

Background the test process and use wait so that the SIGTERM trap fires. The handler waits for the child to finish its own signal handling before exiting.

Motivation

This allows test authors to register SIGTERM handlers for graceful shutdown and resource cleanup during coverage runs.

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

RELNOTES: None

Bash does not run trap handlers while a foreground process is executing.

When Bazel sends SIGTERM on test timeout, the coverage wrapper dies
immediately, meaning that the test process has no opportunity to shut
down gracefully or clean up resources.

Background the test process and use wait so that the SIGTERM trap fires.
The handler waits for the child to finish its own signal handling before
exiting.
@olbapmar olbapmar marked this pull request as ready for review May 18, 2026 12:48
@olbapmar olbapmar requested a review from lberki as a code owner May 18, 2026 12:48
@github-actions github-actions Bot added the awaiting-review PR is awaiting review from an assigned reviewer label May 18, 2026
@iancha1992 iancha1992 added coverage team-Rules-CPP Issues for C++ rules labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer coverage team-Rules-CPP Issues for C++ rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants