Skip to content

Fix resource cleanup for signal shutdown#8847

Merged
chrisduerr merged 6 commits intoalacritty:masterfrom
chrisduerr:clean_kill
Mar 5, 2026
Merged

Fix resource cleanup for signal shutdown#8847
chrisduerr merged 6 commits intoalacritty:masterfrom
chrisduerr:clean_kill

Conversation

@chrisduerr
Copy link
Member

This fixes an issue where Alacritty's resources, like its socket, would stick around after getting killed, since termination signals like SIGTERM were not handled explicitly.

To handle these signals, a new worker thread is spawned that just listens for SIGTERM and SIGINT using signal-hook, which we were already pulling for alacritty_terminal anyway.

While this does not provide support for Windows, we also do not have an IPC socket on Windows we need to clean up. The current Signals implementation does not support Windows, but alternatives like the ctrlc crate exist.

This does spawn a dedicated thread which is going to sit idle for the entire lifetime of Alacritty, which is somewhat unfortunate. However since Winit does not support listening for files like the pipes supported by signal-hook, this seems like the only solution which would not require significant effort in winit.

Closes #8805.


I kinda hate this, but it's probably better than not cleaning up the IPC socket.

@chrisduerr chrisduerr requested a review from kchibisov February 20, 2026 00:30
@chrisduerr chrisduerr force-pushed the clean_kill branch 2 times, most recently from 7829111 to a026b73 Compare February 20, 2026 00:31
@chrisduerr chrisduerr force-pushed the clean_kill branch 3 times, most recently from 8804318 to c6b2acf Compare March 1, 2026 16:28
@chrisduerr chrisduerr requested a review from kchibisov March 1, 2026 16:28
@chrisduerr
Copy link
Member Author

Rewrote the IPC thread to act as a generic I/O event listener and that honestly cleaned up things very nicely. If inotify could integrate into that too it would be beautiful tbh (but not planning on that in this patch).

This fixes an issue where Alacritty's resources, like its socket, would
stick around after getting killed, since termination signals like
SIGTERM were not handled explicitly.

To handle these signals, a new worker thread is spawned that just
listens for SIGTERM and SIGINT using signal-hook, which we were already
pulling for alacritty_terminal anyway.

While this does not provide support for Windows, we also do not have an
IPC socket on Windows we need to clean up. The current `Signals`
implementation does not support Windows, but alternatives like the
`ctrlc` crate exist.

This does spawn a dedicated thread which is going to sit idle for the
entire lifetime of Alacritty, which is somewhat unfortunate. However
since Winit does not support listening for files like the pipes
supported by signal-hook, this seems like the only solution which would
not require significant effort in winit.

Closes alacritty#8805.
While technically this isn't needed, since signals always cause
shutdown, this might be useful if we ever add support for handling other
signals.
@chrisduerr chrisduerr merged commit 96f488d into alacritty:master Mar 5, 2026
5 checks passed
@chrisduerr chrisduerr deleted the clean_kill branch March 5, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

alacritty --daemon doesn't close its socket

2 participants