@@ -646,36 +646,41 @@ func (s *service) checkProcesses(e runcC.Exit) {
646646 defer s .mu .Unlock ()
647647
648648 for _ , container := range s .containers {
649- if container .HasPid (e .Pid ) {
650- shouldKillAll , err := shouldKillAllOnExit (container .Bundle )
651- if err != nil {
652- log .G (s .context ).WithError (err ).Error ("failed to check shouldKillAll" )
649+ if ! container .HasPid (e .Pid ) {
650+ continue
651+ }
652+
653+ for _ , p := range container .All () {
654+ if p .Pid () != e .Pid {
655+ continue
653656 }
654657
655- for _ , p := range container .All () {
656- if p .Pid () == e .Pid {
657- if shouldKillAll {
658- if ip , ok := p .(* process.Init ); ok {
659- // Ensure all children are killed
660- if err := ip .KillAll (s .context ); err != nil {
661- logrus .WithError (err ).WithField ("id" , ip .ID ()).
662- Error ("failed to kill init's children" )
663- }
664- }
658+ if ip , ok := p .(* process.Init ); ok {
659+ shouldKillAll , err := shouldKillAllOnExit (container .Bundle )
660+ if err != nil {
661+ log .G (s .context ).WithError (err ).Error ("failed to check shouldKillAll" )
662+ }
663+
664+ // Ensure all children are killed
665+ if shouldKillAll {
666+ if err := ip .KillAll (s .context ); err != nil {
667+ logrus .WithError (err ).WithField ("id" , ip .ID ()).
668+ Error ("failed to kill init's children" )
665669 }
666- p .SetExited (e .Status )
667- s .sendL (& eventstypes.TaskExit {
668- ContainerID : container .ID ,
669- ID : p .ID (),
670- Pid : uint32 (e .Pid ),
671- ExitStatus : uint32 (e .Status ),
672- ExitedAt : p .ExitedAt (),
673- })
674- return
675670 }
676671 }
672+
673+ p .SetExited (e .Status )
674+ s .sendL (& eventstypes.TaskExit {
675+ ContainerID : container .ID ,
676+ ID : p .ID (),
677+ Pid : uint32 (e .Pid ),
678+ ExitStatus : uint32 (e .Status ),
679+ ExitedAt : p .ExitedAt (),
680+ })
677681 return
678682 }
683+ return
679684 }
680685}
681686
0 commit comments