From 511497f6925e63faba9d7224b910d88c31e0dbb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=2E=C3=87a=C4=9Flar=20Onur?= Date: Tue, 13 Dec 2016 10:13:45 -0800 Subject: [PATCH] trigger child reaper on start (#3487) by seeding the incoming channel. This is required to collect the zombies created by switch-root. --- lib/tether/tether.go | 3 +++ lib/tether/tether_darwin.go | 4 ++++ lib/tether/tether_linux.go | 6 ++++++ lib/tether/tether_windows.go | 4 ++++ 4 files changed, 17 insertions(+) diff --git a/lib/tether/tether.go b/lib/tether/tether.go index cd27d7b4ff..ed627187a8 100644 --- a/lib/tether/tether.go +++ b/lib/tether/tether.go @@ -157,6 +157,9 @@ func (t *tether) setup() error { log.Errorf("Unable to open PID file for %s : %s", os.Args[0], err) } + // seed the incoming channel once to trigger child reaper. This is required to collect the zombies created by switch-root + t.triggerReaper() + return nil } diff --git a/lib/tether/tether_darwin.go b/lib/tether/tether_darwin.go index 4f92a79808..45d066631f 100644 --- a/lib/tether/tether_darwin.go +++ b/lib/tether/tether_darwin.go @@ -41,6 +41,10 @@ func (t *tether) stopReaper() { defer trace.End(trace.Begin("Shutting down child reaping")) } +func (t *tether) triggerReaper() error { + return errors.New("Child reaping unimplemented on OSX") +} + // processEnvOS does OS specific checking and munging on the process environment prior to launch func (t *tether) processEnvOS(env []string) []string { // TODO: figure out how we're going to specify user and pass all the settings along diff --git a/lib/tether/tether_linux.go b/lib/tether/tether_linux.go index 744b067c38..6f83447ac8 100644 --- a/lib/tether/tether_linux.go +++ b/lib/tether/tether_linux.go @@ -151,6 +151,12 @@ func (t *tether) stopReaper() { close(t.incoming) } +func (t *tether) triggerReaper() { + defer trace.End(trace.Begin("Triggering child reaping")) + + t.incoming <- syscall.SIGCHLD +} + func findExecutable(file string) error { d, err := os.Stat(file) if err != nil { diff --git a/lib/tether/tether_windows.go b/lib/tether/tether_windows.go index 97a9cedb65..c57afd5cdf 100644 --- a/lib/tether/tether_windows.go +++ b/lib/tether/tether_windows.go @@ -33,6 +33,10 @@ func (t *tether) stopReaper() { defer trace.End(trace.Begin("Shutting down child reaping")) } +func (t *tether) triggerReaper() error { + return errors.New("Child reaping unimplemented on windows") +} + func lookPath(file string, env []string, dir string) (string, error) { return "", errors.New("unimplemented on windows") }