Skip to content

Add log messages for when a process gets terminated because the task is cancelled #2206

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

Merged
merged 1 commit into from
Jul 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Sources/TSCExtensions/Process+Run.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ extension Process {
}
return try await waitUntilExit()
} onCancel: {
logger.debug("Terminating process using SIGINT because task was cancelled: \(self.arguments)")
signal(SIGINT)
Task {
// Give the process 2 seconds to react to a SIGINT. If that doesn't work, terminate the process.
try await Task.sleep(for: .seconds(2))
if !hasExited.value {
logger.debug("Terminating process using SIGKILL because it did not honor SIGINT: \(self.arguments)")
// TODO: We should also terminate all child processes (https://github.com/swiftlang/sourcekit-lsp/issues/2080)
#if os(Windows)
// Windows does not define SIGKILL. Process.signal sends a `terminate` to the underlying Foundation process
Expand Down