Skip to content

terminal: Fix terminal freeze when child process is killed by signal#47420

Merged
smitbarmase merged 4 commits intomainfrom
fix-terminal-freeze-on-sigsegv
Jan 25, 2026
Merged

terminal: Fix terminal freeze when child process is killed by signal#47420
smitbarmase merged 4 commits intomainfrom
fix-terminal-freeze-on-sigsegv

Conversation

@smitbarmase
Copy link
Member

@smitbarmase smitbarmase commented Jan 22, 2026

Closes #38168
Closes #42414

We were already using ExitStatusExt::from_raw() to construct an ExitStatus, but we were passing in the exit code from alacritty_terminal's ChildExit event. This worked fine on Windows where from_raw() expects an exit code, but on Unix, from_raw() (read more) expects a raw wait status from waitpid() and not an exit code.

When a child process was killed by a signal (e.g., SIGSEGV), ExitStatus::code() returns None since only normal exits have an exit code. This caused the terminal to hang because we weren't properly detecting the exit.

One fix would have been to remove the dependency on ExitStatus entirely, but using the raw wait status gives us more information, we can now detect exit codes, signal terminations, and more.

The actual fix was upstream in alacritty_terminal to send the raw wait status instead of just the exit code.

Currently using forked patch https://github.com/zed-industries/alacritty/tree/v0.16-child-exit-patch which is based on v0.25.1.

Upstream PR: alacritty/alacritty#8825

Release Notes:

  • Fixed terminal hanging when a child process is killed by a signal (e.g., SIGSEGV from null pointer dereference).

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 22, 2026
@smitbarmase smitbarmase merged commit b584192 into main Jan 25, 2026
27 checks passed
@smitbarmase smitbarmase deleted the fix-terminal-freeze-on-sigsegv branch January 25, 2026 09:32
smitbarmase added a commit that referenced this pull request Feb 10, 2026
Follow-up to #47420 and #44193.

#47420 fixed child-exit status handling via upstream alacritty change
(alacritty/alacritty#8825). However,
stable/preview/nightly builds still reproduced hangs that dev builds did
not.

The root cause matches #44193: spawned children inherit crash-handler
Mach exception ports and hang. We already reset exception ports in
`util::command::new_smol_command` and
`util::set_pre_exec_to_start_new_session`, but PTY child spawning in
`alacritty_terminal` was not covered.

This PR updates `alacritty_terminal` to include PTY `pre_exec`
exception-port reset:

zed-industries/alacritty@9d9640d

Upstream:
- alacritty/alacritty#8835

Release Notes:

- Fixed terminal tasks hanging on macOS when a spawned process is killed
by a signal.
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.

SIGSEGV hangs executables from the Zed terminal terminal: nil pointer panic in Go hangs task runner and in agent terminal tool

1 participant