# Fix file descriptor leak when process spawning failed on macOS \(\#59128\) · gitcafe/zed

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

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

Visibility: public

Requested revision: e1bfcf85db56f75a2f6d67143aad2da22c3d2240

Requested commit: e1bfcf85db56f75a2f6d67143aad2da22c3d2240

Commit: e1bfcf85db56f75a2f6d67143aad2da22c3d2240

Tree: 3a119ae8375306836cdad7bc77501edec213c7d8

Author: Cole Miller

Committer: GitHub

## Message

```
Fix file descriptor leak when process spawning failed on macOS (#59128)

Wrap the fds returned by `create_pipe` and `open_dev_null` in
`std::fs::File` earlier, so that they are closed if we return early due
to an error. Includes a regression test.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed a file descriptor leak on macOS.

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
```

## Parents

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

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