File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,6 +71,10 @@ func killProcess(pid int) error {
7171 const timeout = 2 * time .Second
7272 err := syscall .Kill (pid , unix .SIGKILL )
7373 if err != nil {
74+ if errors .Is (err , syscall .ESRCH ) {
75+ // Process already dead, nothing to do
76+ return nil
77+ }
7478 return err
7579 }
7680 deadline := time .Now ().Add (timeout )
Original file line number Diff line number Diff line change @@ -555,18 +555,23 @@ func (u *Unikontainer) Kill() error {
555555 if err != nil {
556556 return err
557557 }
558- err = vmm .Stop (u .State .Pid )
559- if err != nil {
560- return err
558+ // Attempt to stop VMM process. If it's already dead, vmm.Stop() returns nil.
559+ // We save any error but continue with network cleanup regardless.
560+ stopErr := vmm .Stop (u .State .Pid )
561+ if stopErr != nil {
562+ uniklog .Warnf ("vmm.Stop returned error (will continue with cleanup): %v" , stopErr )
561563 }
562564
565+ // Always clean up network resources, regardless of VMM state.
566+ // The TAP device and TC rules exist independently of the VMM process.
563567 // TODO: tap0_urunc should not be hardcoded
564- err = network .Cleanup ("tap0_urunc" )
565- if err != nil {
566- uniklog .Errorf ("failed to delete tap0_urunc: %v" , err )
568+ cleanupErr : = network .Cleanup ("tap0_urunc" )
569+ if cleanupErr != nil {
570+ uniklog .Errorf ("failed to delete tap0_urunc: %v" , cleanupErr )
567571 }
568572
569- return nil
573+ // Return vmm.Stop error if any (network cleanup errors are logged but not fatal)
574+ return stopErr
570575}
571576
572577// Delete removes the containers base directory and its contents
You can’t perform that action at this time.
0 commit comments