Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

100% CPU when --wait-after-command process exits #4884

Closed
mitchellh opened this issue Jan 9, 2025 · 1 comment · Fixed by #5351
Closed

100% CPU when --wait-after-command process exits #4884

mitchellh opened this issue Jan 9, 2025 · 1 comment · Fixed by #5351
Milestone

Comments

@mitchellh
Copy link
Contributor

Reproduction:

  1. zig build run -Dapp-runtime=glfw -- --wait-after-command=true
  2. Type exit in the launched window
  3. See CPU usage

There was a previously attempted fix at #4171 but it caused #4882.

I suspect there is some relation to #4554 as well in the sense that all of our process management there is suspicious.

@AvicennaJr
Copy link

Could this be related to this scenario:

  • I open the terminal
  • I split the terminal (Down or Right)
  • I try to exit the first pane
  • It hangs

You can see the video below to understand better:

ghostty_bug-2025-01-10_11.35.07.mp4

mitchellh added a commit that referenced this issue Jan 24, 2025
Fixes #4884

When our command exits, it will close the pty slave fd. This will
trigger a HUP on our poll. Previously, we only checked for IN. When a fd
is closed, IN triggers forever which would leave to an infinite loop and
100% CPU.

Now, detect the HUP and exit the read thread.
mitchellh added a commit that referenced this issue Jan 24, 2025
Fixes #4884

When our command exits, it will close the pty slave fd. This will
trigger a HUP on our poll. Previously, we only checked for IN. When a fd
is closed, IN triggers forever which would leave to an infinite loop and
100% CPU.

Now, detect the HUP and exit the read thread.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants