File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ actor ManagedContainer {
3030 private let bundle : ContainerizationOCI . Bundle
3131 private var execs : [ String : ManagedProcess ] = [ : ]
3232
33- var pid : Int32 {
33+ var pid : Int32 ? {
3434 self . initProcess. pid
3535 }
3636
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ final class ManagedProcess: Sendable {
4949 let io : IO
5050 var waiters : [ CheckedContinuation < ExitStatus , Never > ] = [ ]
5151 var exitStatus : ExitStatus ? = nil
52- var pid : Int32 = 0
52+ var pid : Int32 ?
5353 }
5454
5555 private static let ackPid = " AckPid "
@@ -67,7 +67,7 @@ final class ManagedProcess: Sendable {
6767 private let bundle : ContainerizationOCI . Bundle
6868 private let cgroupManager : Cgroup2Manager ?
6969
70- var pid : Int32 {
70+ var pid : Int32 ? {
7171 self . state. withLock {
7272 $0. pid
7373 }
@@ -286,12 +286,16 @@ extension ManagedProcess {
286286
287287 func kill( _ signal: Int32 ) throws {
288288 try self . state. withLock {
289+ guard let pid = $0. pid else {
290+ throw ContainerizationError ( . invalidState, message: " process PID is required " )
291+ }
292+
289293 guard $0. exitStatus == nil else {
290294 return
291295 }
292296
293- self . log. info ( " sending signal \( signal) to process \( $0 . pid) " )
294- guard Foundation . kill ( $0 . pid, signal) == 0 else {
297+ self . log. info ( " sending signal \( signal) to process \( pid) " )
298+ guard Foundation . kill ( pid, signal) == 0 else {
295299 throw POSIXError . fromErrno ( )
296300 }
297301 }
Original file line number Diff line number Diff line change @@ -80,8 +80,7 @@ actor ProcessSupervisor {
8080 }
8181
8282 for proc in exitedProcesses {
83- let pid = proc. pid
84- if pid <= 0 {
83+ guard let pid = proc. pid else {
8584 continue
8685 }
8786
You can’t perform that action at this time.
0 commit comments