From c8b37ce0206cf24611cac98bd355fe40ddf8b56c Mon Sep 17 00:00:00 2001 From: Peter Morjan Date: Fri, 3 Feb 2017 10:28:26 +0100 Subject: [PATCH] remove global SIGCHILD handler to avoid conflicts Executing Qemu via cmd.Run() installs it's own SIG handler to wait until Qemu has become a daemon. Under certain conditions the global SIGCHILD handler in containerd.go catches the SIGCHILD from the qemu process and the process is gone. Later on in /usr/local/go/src/os/wait_waitid.go the syscall SYS_WAITID triggerd by cmd.Run() also starts waiting for the process to become waitable but panics with 'waitid: no child processes'. This patch removes the global SIGCHILD handler. Signed-off-by: Peter Morjan --- containerd/containerd.go | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/containerd/containerd.go b/containerd/containerd.go index 8507fd05..c25b3e95 100644 --- a/containerd/containerd.go +++ b/containerd/containerd.go @@ -12,7 +12,6 @@ import ( "github.com/codegangsta/cli" "github.com/docker/containerd/api/grpc/types" - "github.com/docker/containerd/osutils" "github.com/golang/glog" "github.com/hyperhq/runv/containerd/api/grpc/server" "github.com/hyperhq/runv/driverloader" @@ -137,28 +136,17 @@ var ContainerdCommand = cli.Command{ } func daemon(sv *supervisor.Supervisor, address string) error { - // setup a standard reaper so that we don't leave any zombies if we are still alive - // this is just good practice because we are spawning new processes s := make(chan os.Signal, 2048) - signal.Notify(s, syscall.SIGCHLD, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT) + signal.Notify(s, syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT) server, err := startServer(address, sv) if err != nil { return err } - for ss := range s { - switch ss { - case syscall.SIGCHLD: - if _, err := osutils.Reap(); err != nil { - glog.Infof("containerd: reap child processes") - } - default: - glog.Infof("stopping containerd after receiving %s", ss) - time.Sleep(3 * time.Second) // TODO: fix it by proper way - server.Stop() - return nil - } - } + sig := <-s + glog.Infof("stopping containerd after receiving %s", sig) + time.Sleep(3 * time.Second) // TODO: fix it by proper way + server.Stop() return nil }