Skip to content

Commit caa74da

Browse files
committed
Kill native processes on LinuxContainer.kill
Native processes should be managed the same as init process as they are direct children of vminitd process. Thus, they should receive a signal as well when container receives a signal. Additional update: - Update comments for `LinuxContainer.exec`
1 parent 13b3b52 commit caa74da

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

Sources/Containerization/LinuxContainer.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,11 @@ extension LinuxContainer {
849849
public func kill(_ signal: Signal) async throws {
850850
try await self.state.withLock {
851851
let state = try $0.startedState("kill")
852+
853+
for process in state.vendedProcesses.values where process.native {
854+
try await process.kill(signal)
855+
}
856+
852857
try await state.process.kill(signal)
853858
}
854859
}
@@ -915,7 +920,7 @@ extension LinuxContainer {
915920
}
916921

917922
/// Execute a new process in the container. The process is not started after this call, and must be manually started
918-
/// via the `start` method.
923+
/// via the `start` method. When `native` is true, the process is created outside of container, running in the root of VM.
919924
public func exec(_ id: String, configuration: LinuxProcessConfiguration, native: Bool = false) async throws -> LinuxProcess {
920925
try await self.state.withLock {
921926
var state = try $0.startedState("exec")

Sources/Containerization/LinuxProcess.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public final class LinuxProcess: Sendable {
9494

9595
private let state: Mutex<State>
9696
private let ioSetup: Stdio
97-
private let native: Bool
97+
let native: Bool
9898
private let agent: any VirtualMachineAgent
9999
private let vm: any VirtualMachineInstance
100100
private let ociRuntimePath: String?

0 commit comments

Comments
 (0)