Skip to content

Conversation

@ahoppen
Copy link
Member

@ahoppen ahoppen commented Mar 20, 2025

When SourceKit-LSP is shut down, we should make sure that we don’t leave behind child processes, which will become orphans after SourceKit-LSP has terminated. What’s worse, when SourceKit-LSP has exited, these processes might not have any process to read their stdout/stderr, which can lead to them running indefinitely.

This change does not cover the termination of subprocess trees. For example, if we launch swift build and need to kill it because it doesn’t honor SIGINT, its child processes will still live on. Similarly, if we kill a BSP server, its child processes might live on. Fixing this is a drastically bigger endeavor, likely requiring changes to Foundation and/or TSC. I filed #2080 for it.

@ahoppen ahoppen force-pushed the cancel-in-progress-indexing branch from b92e2df to c22dc37 Compare March 20, 2025 23:49
@ahoppen
Copy link
Member Author

ahoppen commented Mar 20, 2025

@swift-ci Please test

1 similar comment
@ahoppen
Copy link
Member Author

ahoppen commented Mar 21, 2025

@swift-ci Please test

@ahoppen ahoppen force-pushed the cancel-in-progress-indexing branch from c22dc37 to 2307807 Compare March 21, 2025 23:49
@ahoppen
Copy link
Member Author

ahoppen commented Mar 21, 2025

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 21, 2025

@swift-ci Please test Windows

@ahoppen
Copy link
Member Author

ahoppen commented Mar 21, 2025

@swift-ci Please test Linux

@ahoppen
Copy link
Member Author

ahoppen commented Mar 22, 2025

@swift-ci Please test Linux

@ahoppen ahoppen force-pushed the cancel-in-progress-indexing branch from 2307807 to 77da5fd Compare March 24, 2025 21:03
@ahoppen
Copy link
Member Author

ahoppen commented Mar 24, 2025

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 24, 2025

@swift-ci Please test Windows

@ahoppen ahoppen force-pushed the cancel-in-progress-indexing branch from 77da5fd to 3367496 Compare March 25, 2025 16:27
@ahoppen
Copy link
Member Author

ahoppen commented Mar 25, 2025

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 25, 2025

@swift-ci Please test Windows

…ting down SourceKit-LSP

When SourceKit-LSP is shut down, we should make sure that we don’t leave behind child processes, which will become orphans after SourceKit-LSP has terminated. What’s worse, when SourceKit-LSP has exited, these processes might not have any process to read their stdout/stderr, which can lead to them running indefinitely.

This change does not cover the termination of subprocess trees. For example, if we launch `swift build` and need to kill it because it doesn’t honor SIGINT, its child processes will still live on. Similarly, if we kill a BSP server, its child processes might live on. Fixing this is a drastically bigger endeavor, likely requiring changes to Foundation and/or TSC. I filed swiftlang#2080 for it.
@ahoppen ahoppen force-pushed the cancel-in-progress-indexing branch from 3367496 to 3bb4690 Compare March 25, 2025 21:10
@ahoppen
Copy link
Member Author

ahoppen commented Mar 25, 2025

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 25, 2025

@swift-ci Please test Windows

@ahoppen
Copy link
Member Author

ahoppen commented Mar 26, 2025

@swift-ci Please test macOS

@ahoppen ahoppen merged commit 7eba708 into swiftlang:main Mar 26, 2025
3 checks passed
@ahoppen ahoppen deleted the cancel-in-progress-indexing branch March 26, 2025 15:38
ahoppen added a commit to ahoppen/sourcekit-lsp that referenced this pull request May 13, 2025
…down

This is what `shutDown()` is documented to do. I also remember having this check before, it might have gotten lost during a rebase when I was working on swiftlang#2081.

I noticed this while investigating swiftlang#2152: In this case `buildTarget/prepare` was cancelled because the SourceKit-LSP server was shut down but indexing of a file was still started after the shutdown now that preparation had finished (because it was cancelled).
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 this pull request may close these issues.

2 participants