On timeout, notify process leader before sending SIGTERM to all processes
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the problem / feature request:
I'm trying to make our test suite dump its thread state upon hitting the timeout from bazel. Bazel sends a SIGTERM to all processes at once, making it difficult to do this without doing some weird subprocess+PGID hacks that don't play well with other tools (in our case, pdb).
According to https://github.com/bazelbuild/bazel/blob/09c621e4cf5b968f4c6cdf905ab142d5961f9ddc/src/main/tools/process-tools.cc#L93-L98, there is already a TODO to first notify the process leader and give it a chance to clean up before sending a signal to all child processes.
Something like:
- Send SIGTERM to process leader PID
- Wait x seconds
- Send SIGTERM to all processes
- Wait x seconds
- Send SIGKILL
would be great, or maybe skipping the second SIGTERM and going straight to SIGKILL could work too.
### Feature requests: what underlying problem are you trying to solve with this feature?
Ability to run cleanup code that examines child processes before they get terminated by bazel
### Have you found anything relevant by searching the web?
Found some mentions of Java test runner being able to print thread dumps on timeout, but not sure if it's able to grab child thread dumps before they get terminated.
Contributor guide
Research direction
Start with src/main/tools/process-tools.cc at the linked TODO about notifying the process leader before signaling child processes. Review how timeout termination currently sends signals, then verify the chosen sequence gives the leader time to inspect child processes before the remaining processes are terminated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100