# agent_servers: Fix process leaks after terminating ACP server \(\#45902\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/9f599466b5a296e2ff50de10db6a548bf34da881)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 9f599466b5a296e2ff50de10db6a548bf34da881

Requested commit: 9f599466b5a296e2ff50de10db6a548bf34da881

Commit: 9f599466b5a296e2ff50de10db6a548bf34da881

Tree: 4c10347f9158601311d376db90159bc81998a61a

Author: Bennet Bo Fenner

Committer: GitHub

## Message

```
agent_servers: Fix process leaks after terminating ACP server (#45902)

Closes #45211

This ensures that all sub-processes that were launched by the ACP server
are terminated. One scenario where this is easily reproducible:
- Start a new Claude Code ACP session
- Submit a prompt
- While Claude-code is still responding, start a new session
- The `claude-code` subprocess is leaked from the previous session (The
Claude-code SDK runs the Claude-code binary in a sub process)

This PR fixes this by using process groups on Unix. 
It does not fix the process leaks on Windows yet (will follow up with
another PR)

Release Notes:

- Fixed an issue where subprocesses of ACP servers could be leaked after
starting a new session
```

## Parents

- [dffda918382bc73df3e1385372dd832e7166ca87](https://git.cafe/gitcafe/zed/commit/dffda918382bc73df3e1385372dd832e7166ca87?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/9f599466b5a296e2ff50de10db6a548bf34da881?format=markdown)
