File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414
1515import Foundation
1616
17+ #if os(Windows)
18+ import WinSDK
19+ #endif /* os(Windows) */
20+
1721public class JavaScriptExecutor {
1822 /// Path to the js shell binary.
1923 let executablePath : String
@@ -103,11 +107,21 @@ public class JavaScriptExecutor {
103107 break
104108 }
105109 }
106- if task. isRunning {
110+ runningCheck: if task. isRunning {
111+ timedOut = true
112+ #if os(Windows)
113+ guard let processHandle = OpenProcess ( DWORD ( PROCESS_TERMINATE) , false , DWORD ( task. processIdentifier) ) else {
114+ // Fall back to built-in termination
115+ task. terminate ( )
116+ break runningCheck
117+ }
118+ defer { CloseHandle ( processHandle) }
119+ TerminateProcess ( processHandle, 1 )
120+ #else
107121 // Properly kill the task now with SIGKILL as it might be stuck
108122 // in Wasm, where SIGTERM is not enough.
109123 kill ( task. processIdentifier, SIGKILL)
110- timedOut = true
124+ #endif /* os(Windows) */
111125 }
112126 }
113127
You can’t perform that action at this time.
0 commit comments