terminal: Kill entire process group on Unix when stopping command#45993
Merged
Veykril merged 1 commit intozed-industries:mainfrom Jan 5, 2026
Merged
Conversation
Previously, stopping a terminal command only killed the shell process, leaving child processes (like sleep, npm, etc.) running as orphans. Use killpg() instead of kill() on Unix to terminate the entire foreground process group.
|
We require contributors to sign our Contributor License Agreement, and we don't have @DepsCian on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'. |
Contributor
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
Contributor
This comment was marked as spam.
This comment was marked as spam.
rtfeldman
pushed a commit
that referenced
this pull request
Jan 5, 2026
…5993) ## Problem When clicking Stop button on a terminal tool call (or using terminal kill bindings), only the shell process was killed. Child processes (like `sleep`, `npm run`, etc.) continued running as orphans. ## Solution On Unix, use `killpg()` instead of `sysinfo::Process::kill()` to terminate the entire foreground process group. `tcgetpgrp()` already returns the foreground process group ID, so `killpg()` is the correct syscall to use here. ## Testing 1. Run a long command in terminal tool (e.g. `sleep 30`) 2. Click Stop button 3. Verify with `ps aux | grep sleep` that the process is actually killed ## Notes - This fix is Unix-only (Linux, macOS) - Windows behavior unchanged — may need separate investigation with Job Objects ## Release Notes - Fixed terminal Stop button not killing child processes on Unix (Linux, macOS)
LivioGama
pushed a commit
to LivioGama/zed
that referenced
this pull request
Jan 20, 2026
…d-industries#45993) ## Problem When clicking Stop button on a terminal tool call (or using terminal kill bindings), only the shell process was killed. Child processes (like `sleep`, `npm run`, etc.) continued running as orphans. ## Solution On Unix, use `killpg()` instead of `sysinfo::Process::kill()` to terminate the entire foreground process group. `tcgetpgrp()` already returns the foreground process group ID, so `killpg()` is the correct syscall to use here. ## Testing 1. Run a long command in terminal tool (e.g. `sleep 30`) 2. Click Stop button 3. Verify with `ps aux | grep sleep` that the process is actually killed ## Notes - This fix is Unix-only (Linux, macOS) - Windows behavior unchanged — may need separate investigation with Job Objects ## Release Notes - Fixed terminal Stop button not killing child processes on Unix (Linux, macOS)
LivioGama
pushed a commit
to LivioGama/zed
that referenced
this pull request
Jan 20, 2026
…d-industries#45993) ## Problem When clicking Stop button on a terminal tool call (or using terminal kill bindings), only the shell process was killed. Child processes (like `sleep`, `npm run`, etc.) continued running as orphans. ## Solution On Unix, use `killpg()` instead of `sysinfo::Process::kill()` to terminate the entire foreground process group. `tcgetpgrp()` already returns the foreground process group ID, so `killpg()` is the correct syscall to use here. ## Testing 1. Run a long command in terminal tool (e.g. `sleep 30`) 2. Click Stop button 3. Verify with `ps aux | grep sleep` that the process is actually killed ## Notes - This fix is Unix-only (Linux, macOS) - Windows behavior unchanged — may need separate investigation with Job Objects ## Release Notes - Fixed terminal Stop button not killing child processes on Unix (Linux, macOS)
LivioGama
pushed a commit
to LivioGama/zed
that referenced
this pull request
Feb 15, 2026
…d-industries#45993) ## Problem When clicking Stop button on a terminal tool call (or using terminal kill bindings), only the shell process was killed. Child processes (like `sleep`, `npm run`, etc.) continued running as orphans. ## Solution On Unix, use `killpg()` instead of `sysinfo::Process::kill()` to terminate the entire foreground process group. `tcgetpgrp()` already returns the foreground process group ID, so `killpg()` is the correct syscall to use here. ## Testing 1. Run a long command in terminal tool (e.g. `sleep 30`) 2. Click Stop button 3. Verify with `ps aux | grep sleep` that the process is actually killed ## Notes - This fix is Unix-only (Linux, macOS) - Windows behavior unchanged — may need separate investigation with Job Objects ## Release Notes - Fixed terminal Stop button not killing child processes on Unix (Linux, macOS)
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.
Problem
When clicking Stop button on a terminal tool call (or using terminal kill bindings), only the shell process was killed. Child processes (like
sleep,npm run, etc.) continued running as orphans.Solution
On Unix, use
killpg()instead ofsysinfo::Process::kill()to terminate the entire foreground process group.tcgetpgrp()already returns the foreground process group ID, sokillpg()is the correct syscall to use here.Testing
sleep 30)ps aux | grep sleepthat the process is actually killedNotes
Release Notes