Skip to content

Fix git hang caused by accidental inheritance of stdin FD (#57572) (cherry-pick to preview)#57661

Merged
maxbrunsfeld merged 1 commit into
v1.4.xfrom
cherry-pick-v1.4.x-2e208604
May 25, 2026
Merged

Fix git hang caused by accidental inheritance of stdin FD (#57572) (cherry-pick to preview)#57661
maxbrunsfeld merged 1 commit into
v1.4.xfrom
cherry-pick-v1.4.x-2e208604

Conversation

@zed-zippy

@zed-zippy zed-zippy Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Cherry-pick of #57572 to preview


When restarting Zed, I hit a bug where all Git operations were hung. I
realized that there was a hanging git process running git cat-file --batch-check=%(objectname). The process was waiting on stdin. This was
surprising, because the
code

that spawns this process explicitly closes the pipe that is attached to
the process's stdin after writing a list of ref names.

Using Claude, I found that this could be caused by that pipe file
descriptor being cloned due to file descriptor inheritance when another
child process is exec'd while that stdin pipe is open. The fix is to
enhance our Darwin process spawning layer to set the close-on-exec flag
for the pipe file descriptors, so that they are not inherited by child
processes spawned using code paths that don't set
POSIX_SPAWN_CLOEXEC_DEFAULT.

Release Notes:

  • Fixed a bug on macOS where Git operations could be blocked depending
    on the timing of spawning child processes.

When restarting Zed, I hit a bug where all Git operations were hung. I
realized that there was a hanging git process running `git cat-file
--batch-check=%(objectname)`. The process was waiting on stdin. This was
surprising, because [the
code](https://github.com/zed-industries/zed/blob/e2bbdb19b6da2ee157ca1d36100acde2134a1663/crates/git/src/repository.rs#L1665-L1709)
that spawns this process explicitly closes the pipe that is attached to
the process's stdin after writing a list of ref names.

Using Claude, I found that this could be caused by that pipe file
descriptor being cloned due to file descriptor inheritance when another
child process is `exec`'d while that stdin pipe is open. The fix is to
enhance our Darwin process spawning layer to set the close-on-exec flag
for the pipe file descriptors, so that they are not inherited by child
processes spawned using code paths that don't set
`POSIX_SPAWN_CLOEXEC_DEFAULT`.

Release Notes:

- Fixed a bug on macOS where Git operations could be blocked depending
on the timing of spawning child processes.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 25, 2026
@zed-community-bot zed-community-bot Bot added the bot Pull requests authored by a bot label May 25, 2026
@maxbrunsfeld maxbrunsfeld enabled auto-merge (squash) May 25, 2026 16:33
@maxbrunsfeld maxbrunsfeld merged commit 4e51699 into v1.4.x May 25, 2026
61 of 63 checks passed
@maxbrunsfeld maxbrunsfeld deleted the cherry-pick-v1.4.x-2e208604 branch May 25, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot Pull requests authored by a bot cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant