Stop the launcher killing the app that is running - #265
Merged
Merged
Conversation
kill_stale() clears a leftover sidecar off the port before
spawning a new one. On unix it asked:
lsof -ti :8765
which matches any socket with that port on either end, so
it lists the server and everything connected to it.
Measured on macOS with one listener and one client:
lsof -ti :PORT -> 90713 90735
lsof -ti :PORT -sTCP:LISTEN -> 90713
The busiest client of the sidecar is the webview of a
kaisho-desktop that is still running, so an auto-update
restart or a second launch would SIGTERM the instance
already on screen, along with anything else holding a
connection to 127.0.0.1:8765.
The Windows branch, ten lines below, already guards
against precisely this. Its comment spells out the failure
and even names the case: including, on a bad day,
kaisho-desktop itself since the webview connects back to
port 8765. That fix landed for netstat and never reached
lsof, and macOS is the platform this ships on first.
-sTCP:LISTEN restricts it to the listener, and the loop
also skips its own pid, which is cheap and makes the
intent explicit.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
kill_stale()clears a leftover sidecar off the port before spawning a new one. On unix it asked:which matches any socket with that port on either end, so it lists the server and everything connected to it. Measured on macOS with one listener and one client:
The busiest client of the sidecar is the webview of a kaisho-desktop that is still running, so an auto-update restart or a second launch would SIGTERM the instance already on screen, along with anything else holding a connection to 127.0.0.1:8765.
The Windows branch, ten lines below, already guards against precisely this. Its comment spells out the failure and even names the case:
That fix landed for
netstatand never reachedlsof. macOS is the platform this ships on first.-sTCP:LISTENrestricts it to the listener, and the loop also skips its own pid, which is cheap and makes the intent explicit. Builds clean, clippy unchanged.