Skip to content

Commit 70ec1bf

Browse files
committed
Add log messages for when a process gets terminated because the task is cancelled
I hope this makes it easier to spot why a `swift build` launched for target preparation does not get terminated when the preparation task is cancelled, as we saw in https://ci-external.swift.org/job/sourcekit-lsp-PR-windows/3089/.
1 parent d2e5bd7 commit 70ec1bf

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Sources/TSCExtensions/Process+Run.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ extension Process {
3838
}
3939
return try await waitUntilExit()
4040
} onCancel: {
41+
logger.debug("Terminating process using SIGINT because task was cancelled: \(self.arguments)")
4142
signal(SIGINT)
4243
Task {
4344
// Give the process 2 seconds to react to a SIGINT. If that doesn't work, terminate the process.
4445
try await Task.sleep(for: .seconds(2))
4546
if !hasExited.value {
47+
logger.debug("Terminating process using SIGKILL because it did not honor SIGINT: \(self.arguments)")
4648
// TODO: We should also terminate all child processes (https://github.com/swiftlang/sourcekit-lsp/issues/2080)
4749
#if os(Windows)
4850
// Windows does not define SIGKILL. Process.signal sends a `terminate` to the underlying Foundation process

0 commit comments

Comments
 (0)