Skip to content

terminal: Kill entire process group on Unix when stopping command#45993

Merged
Veykril merged 1 commit intozed-industries:mainfrom
DepsCian:fix/terminal-kill-process-group
Jan 5, 2026
Merged

terminal: Kill entire process group on Unix when stopping command#45993
Veykril merged 1 commit intozed-industries:mainfrom
DepsCian:fix/terminal-kill-process-group

Conversation

@DepsCian
Copy link
Contributor

@DepsCian DepsCian commented Jan 3, 2026

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)

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.
@cla-bot
Copy link

cla-bot bot commented Jan 3, 2026

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'.

@DepsCian
Copy link
Contributor Author

DepsCian commented Jan 3, 2026

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 3, 2026
@cla-bot
Copy link

cla-bot bot commented Jan 3, 2026

The cla-bot has been summoned, and re-checked this pull request!

@maxdeviant maxdeviant changed the title fix(terminal): kill entire process group on Unix when stopping command terminal: Kill entire process group on Unix when stopping command Jan 3, 2026
@zed-industries-bot
Copy link
Contributor

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against b3adcf2

@DepsCian

This comment was marked as spam.

Copy link
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@Veykril Veykril merged commit 01b716c into zed-industries:main Jan 5, 2026
26 checks passed
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants