@@ -511,33 +511,35 @@ func (s *Service) allProcesses() []rproc.Process {
511511}
512512
513513func (s * Service ) checkProcesses (e runc.Exit ) {
514- shouldKillAll , err := shouldKillAllOnExit (s .bundle )
515- if err != nil {
516- log .G (s .context ).WithError (err ).Error ("failed to check shouldKillAll" )
517- }
518-
519514 for _ , p := range s .allProcesses () {
520- if p .Pid () == e .Pid {
515+ if p .Pid () != e .Pid {
516+ continue
517+ }
521518
519+ if ip , ok := p .(* proc.Init ); ok {
520+ shouldKillAll , err := shouldKillAllOnExit (s .bundle )
521+ if err != nil {
522+ log .G (s .context ).WithError (err ).Error ("failed to check shouldKillAll" )
523+ }
524+
525+ // Ensure all children are killed
522526 if shouldKillAll {
523- if ip , ok := p .(* proc.Init ); ok {
524- // Ensure all children are killed
525- if err := ip .KillAll (s .context ); err != nil {
526- log .G (s .context ).WithError (err ).WithField ("id" , ip .ID ()).
527- Error ("failed to kill init's children" )
528- }
527+ if err := ip .KillAll (s .context ); err != nil {
528+ log .G (s .context ).WithError (err ).WithField ("id" , ip .ID ()).
529+ Error ("failed to kill init's children" )
529530 }
530531 }
531- p .SetExited (e .Status )
532- s .events <- & eventstypes.TaskExit {
533- ContainerID : s .id ,
534- ID : p .ID (),
535- Pid : uint32 (e .Pid ),
536- ExitStatus : uint32 (e .Status ),
537- ExitedAt : p .ExitedAt (),
538- }
539- return
540532 }
533+
534+ p .SetExited (e .Status )
535+ s .events <- & eventstypes.TaskExit {
536+ ContainerID : s .id ,
537+ ID : p .ID (),
538+ Pid : uint32 (e .Pid ),
539+ ExitStatus : uint32 (e .Status ),
540+ ExitedAt : p .ExitedAt (),
541+ }
542+ return
541543 }
542544}
543545
0 commit comments