diff --git a/Sources/Containerization/LinuxContainer.swift b/Sources/Containerization/LinuxContainer.swift index ecc287aa..2ff55169 100644 --- a/Sources/Containerization/LinuxContainer.swift +++ b/Sources/Containerization/LinuxContainer.swift @@ -566,7 +566,7 @@ extension LinuxContainer { } // Lets free up the init procs resources, as this includes the open agent conn. - try? await startedState.process.delete() + try await startedState.process.delete() try await startedState.vm.stop() state = .stopped diff --git a/Sources/Containerization/LinuxProcess.swift b/Sources/Containerization/LinuxProcess.swift index bacc8d40..83e544f5 100644 --- a/Sources/Containerization/LinuxProcess.swift +++ b/Sources/Containerization/LinuxProcess.swift @@ -399,12 +399,16 @@ extension LinuxProcess { containerID: self.owningContainer ) } catch { - self.logger?.error( - "process deletion", - metadata: [ - "id": "\(self.id)", - "error": "\(error)", - ]) + self.state.withLock { + $0.stdinRelay?.cancel() + try? $0.stdio.close() + } + try? await self.agent.close() + throw ContainerizationError( + .internalError, + message: "failed to delete process", + cause: error, + ) } do { @@ -413,12 +417,12 @@ extension LinuxProcess { try $0.stdio.close() } } catch { - self.logger?.error( - "closing process stdio", - metadata: [ - "id": "\(self.id)", - "error": "\(error)", - ]) + try? await self.agent.close() + throw ContainerizationError( + .internalError, + message: "failed to close stdio", + cause: error, + ) } do {