Don't hog task queue while waiting for exec process

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure 2016-09-12 11:19:54 -07:00
parent 578bf0c70e
commit 920a9c21d7

View file

@ -73,13 +73,19 @@ func (s *Supervisor) execExit(t *ExecExitTask) error {
if err := container.RemoveProcess(t.PID); err != nil { if err := container.RemoveProcess(t.PID); err != nil {
logrus.WithField("error", err).Error("containerd: find container for pid") logrus.WithField("error", err).Error("containerd: find container for pid")
} }
t.Process.Wait() // If the exec spawned children which are still using its IO
s.notifySubscribers(Event{ // waiting here will block until they die or close their IO
Timestamp: time.Now(), // descriptors.
ID: t.ID, // Hence, we use a go routine to avoid block all other operations
Type: StateExit, go func() {
PID: t.PID, t.Process.Wait()
Status: t.Status, s.notifySubscribers(Event{
}) Timestamp: time.Now(),
ID: t.ID,
Type: StateExit,
PID: t.PID,
Status: t.Status,
})
}()
return nil return nil
} }