Skip to content

Commit 6a6577a

Browse files
authored
Preview: remove use of signal on Windows (#26)
Windows does not support signal(2). Instead, use `TerminateProcess` to terminate the process. We will not properly handle the termination of child processes for the preview process, which should be handled by the construction of a job object that all child processes are attached to such that when the parent process is terminated, the children will be properly reaped. This is required to enable building the plugin on Windows which is a dependency for swift-syntax.
1 parent 27b58a6 commit 6a6577a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Plugins/Swift-DocC Preview/SwiftDocCPreview.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
// See https://swift.org/LICENSE.txt for license information
77
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
88

9+
#if os(Windows)
10+
import WinSDK
11+
#endif
912
import Foundation
1013
import PackagePlugin
1114

@@ -125,6 +128,8 @@ import PackagePlugin
125128
func stopPreviewProcess() {
126129
#if os(macOS) && os(iOS) && os(tvOS) && os(watchOS)
127130
previewProcess.interrupt()
131+
#elseif os(Windows)
132+
_ = TerminateProcess(previewProcess.processHandle, 0)
128133
#else
129134
// On non-Darwin systems, `docc` doesn't properly exit with just an interrupt signal
130135
// so send a SIGKILL instead.

0 commit comments

Comments
 (0)