linux: Ensure all init children are dead when it exits

This ensure that when using the host pid, we don't let process alive,
preventing Wait() to return until they all die.

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure
2017-09-01 09:41:37 -07:00
parent 9d251cbd1b
commit 92772bd471
2 changed files with 84 additions and 0 deletions

View File

@@ -393,6 +393,14 @@ func (s *Service) checkProcesses(e runc.Exit) {
defer s.mu.Unlock()
for _, p := range s.processes {
if p.Pid() == e.Pid {
if ip, ok := p.(*initProcess); ok {
// Ensure all children are killed
if err := ip.killAll(s.context); err != nil {
log.G(s.context).WithError(err).WithField("id", ip.ID()).
Error("failed to kill init's children")
}
}
p.SetExited(e.Status)
s.events <- &eventsapi.TaskExit{
ContainerID: s.id,