From 920a9c21d7d26deebc74822ca39a8f9b0121f860 Mon Sep 17 00:00:00 2001 From: Kenfe-Mickael Laventure Date: Mon, 12 Sep 2016 11:19:54 -0700 Subject: [PATCH] Don't hog task queue while waiting for exec process Signed-off-by: Kenfe-Mickael Laventure --- supervisor/exit.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/supervisor/exit.go b/supervisor/exit.go index 442327d..e20ee47 100644 --- a/supervisor/exit.go +++ b/supervisor/exit.go @@ -73,13 +73,19 @@ func (s *Supervisor) execExit(t *ExecExitTask) error { if err := container.RemoveProcess(t.PID); err != nil { logrus.WithField("error", err).Error("containerd: find container for pid") } - t.Process.Wait() - s.notifySubscribers(Event{ - Timestamp: time.Now(), - ID: t.ID, - Type: StateExit, - PID: t.PID, - Status: t.Status, - }) + // If the exec spawned children which are still using its IO + // waiting here will block until they die or close their IO + // descriptors. + // Hence, we use a go routine to avoid block all other operations + go func() { + t.Process.Wait() + s.notifySubscribers(Event{ + Timestamp: time.Now(), + ID: t.ID, + Type: StateExit, + PID: t.PID, + Status: t.Status, + }) + }() return nil }