feat(core): add opt-in kill-on-drop for externally spawned commands - #1244
Merged
reubeno merged 2 commits intoJul 25, 2026
Merged
Conversation
`sys::process::spawn` never sets `kill_on_drop`, so a spawned child outlives the shell that started it. That is correct for a real shell -- it is what makes job control, disowned jobs, and `nohup`-style usage work -- and remains the default. It is wrong for an embedded shell, where the host creates and destroys the shell as an object. There a surviving child keeps running unattended and holds a duplicate of the shell's stdout/stderr pipe, so a host draining that output never observes EOF. Add a `kill_external_commands_on_drop` creation option, defaulting to `false`, plumbed through `RuntimeOptions` to `sys::process::spawn` alongside the existing `external_cmd_leads_session`. The stub backend accepts and ignores it. Process-group behavior is untouched, so this signals the immediate child only. Assisted-by: Claude Code:claude-opus-4-8
The added doc comments were multi-paragraph prose where brush uses one-line field docs. Trim each to match its neighbors; drop the `# Arguments` block on the internal `spawn` (it had no doc before); keep only the non-obvious runtime- teardown note in the test header. Assisted-by: Claude Code:claude-opus-4-8
hartsock
marked this pull request as ready for review
July 20, 2026 14:55
This was referenced Jul 20, 2026
Contributor
Author
Public API changes for crate: brush-coreAdded itemsPerformance Benchmark Report
Code Coverage Report: Only Changed Files listed
Minimum allowed coverage is Test Summary: bash-completion test suite
|
reubeno
approved these changes
Jul 25, 2026
Owner
|
Thanks for the contribution! Agreed that this is valuable for embedded shell hosts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found during practical testing. We were experimenting with spawning shells and the outer process would terminate and leave behind the child shell.
sys::process::spawnnever setskill_on_drop, so a spawned child outlives the shell that started it. That is correct for a real shell — it is what makes job control, disowned jobs, andnohup-style usage work — and remains the default.It is wrong for an embedded shell, where the host creates and destroys the shell as an object. There a surviving child keeps running unattended and holds a duplicate of the shell's stdout/stderr pipe, so a host draining that output never observes EOF.
Adds a
kill_external_commands_on_dropcreation option, defaulting tofalse, plumbed throughRuntimeOptionstosys::process::spawnalongside the existingexternal_cmd_leads_session. The stub backend accepts and ignores it. Process-group behavior is untouched, so this signals the immediate child only.Tests cover both directions and that the option defaults off. Mutation-checked: forcing
kill_on_drop(false)fails the enabled case.