rpc: ensure worker is killed if it hangs on shutdown
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
import Darwin
|
||||||
import OSLog
|
import OSLog
|
||||||
|
|
||||||
struct ControlRequestParams: @unchecked Sendable {
|
struct ControlRequestParams: @unchecked Sendable {
|
||||||
@@ -242,6 +243,12 @@ actor AgentRPC {
|
|||||||
self.stdoutHandle?.readabilityHandler = nil
|
self.stdoutHandle?.readabilityHandler = nil
|
||||||
let proc = self.process
|
let proc = self.process
|
||||||
proc?.terminate()
|
proc?.terminate()
|
||||||
|
if let proc, proc.isRunning {
|
||||||
|
try? await Task.sleep(nanoseconds: 700_000_000)
|
||||||
|
if proc.isRunning {
|
||||||
|
kill(proc.processIdentifier, SIGKILL)
|
||||||
|
}
|
||||||
|
}
|
||||||
proc?.waitUntilExit()
|
proc?.waitUntilExit()
|
||||||
self.process = nil
|
self.process = nil
|
||||||
self.stdinHandle = nil
|
self.stdinHandle = nil
|
||||||
|
|||||||
Reference in New Issue
Block a user