From f611b37834a77a92fd0500e2491bcecff7b65591 Mon Sep 17 00:00:00 2001 From: Jaana Burcu Dogan Date: Wed, 17 Feb 2016 00:10:18 +0100 Subject: [PATCH 1/2] Use a better package name for utility functions. --- containerd-shim/main.go | 6 +++--- containerd/main.go | 8 ++++---- {util => osutils}/fds.go | 2 +- {util => osutils}/prctl.go | 2 +- {util => osutils}/reaper.go | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) rename {util => osutils}/fds.go (95%) rename {util => osutils}/prctl.go (98%) rename {util => osutils}/reaper.go (97%) diff --git a/containerd-shim/main.go b/containerd-shim/main.go index a7dcbe3..ece4cf7 100644 --- a/containerd-shim/main.go +++ b/containerd-shim/main.go @@ -8,7 +8,7 @@ import ( "syscall" "github.com/Sirupsen/logrus" - "github.com/docker/containerd/util" + "github.com/docker/containerd/osutils" "github.com/docker/docker/pkg/term" ) @@ -32,7 +32,7 @@ func main() { signals := make(chan os.Signal, 2048) signal.Notify(signals) // set the shim as the subreaper for all orphaned processes created by the container - if err := util.SetSubreaper(1); err != nil { + if err := osutils.SetSubreaper(1); err != nil { logrus.WithField("error", err).Fatal("shim: set as subreaper") } // open the exit pipe @@ -82,7 +82,7 @@ func main() { logrus.WithField("signal", s).Debug("shim: received signal") switch s { case syscall.SIGCHLD: - exits, err := util.Reap() + exits, err := osutils.Reap() if err != nil { logrus.WithField("error", err).Error("shim: reaping child processes") } diff --git a/containerd/main.go b/containerd/main.go index a5a5558..7ffdf3b 100644 --- a/containerd/main.go +++ b/containerd/main.go @@ -19,8 +19,8 @@ import ( "github.com/docker/containerd" "github.com/docker/containerd/api/grpc/server" "github.com/docker/containerd/api/grpc/types" + "github.com/docker/containerd/osutils" "github.com/docker/containerd/supervisor" - "github.com/docker/containerd/util" "github.com/rcrowley/go-metrics" ) @@ -141,7 +141,7 @@ func processMetrics() { // update number of goroutines g.Update(int64(runtime.NumGoroutine())) // collect the number of open fds - fds, err := util.GetOpenFds(os.Getpid()) + fds, err := osutils.GetOpenFds(os.Getpid()) if err != nil { logrus.WithField("error", err).Error("containerd: get open fd count") } @@ -194,11 +194,11 @@ func daemon(address, stateDir string, concurrency int, oom bool) error { func reapProcesses() { s := make(chan os.Signal, 2048) signal.Notify(s, syscall.SIGCHLD) - if err := util.SetSubreaper(1); err != nil { + if err := osutils.SetSubreaper(1); err != nil { logrus.WithField("error", err).Error("containerd: set subpreaper") } for range s { - if _, err := util.Reap(); err != nil { + if _, err := osutils.Reap(); err != nil { logrus.WithField("error", err).Error("containerd: reap child processes") } } diff --git a/util/fds.go b/osutils/fds.go similarity index 95% rename from util/fds.go rename to osutils/fds.go index 57d490d..98fc930 100644 --- a/util/fds.go +++ b/osutils/fds.go @@ -1,6 +1,6 @@ // +build !windows,!darwin -package util +package osutils import ( "io/ioutil" diff --git a/util/prctl.go b/osutils/prctl.go similarity index 98% rename from util/prctl.go rename to osutils/prctl.go index 1c782e8..eeb3da1 100644 --- a/util/prctl.go +++ b/osutils/prctl.go @@ -1,7 +1,7 @@ // +build linux // http://man7.org/linux/man-pages/man2/prctl.2.html -package util +package osutils import ( "syscall" diff --git a/util/reaper.go b/osutils/reaper.go similarity index 97% rename from util/reaper.go rename to osutils/reaper.go index 34b4c2f..973e417 100644 --- a/util/reaper.go +++ b/osutils/reaper.go @@ -1,4 +1,4 @@ -package util +package osutils import ( "syscall" From 8a8e29bb7b1ee38d42487ab3e472cead154aed7e Mon Sep 17 00:00:00 2001 From: Jaana Burcu Dogan Date: Wed, 17 Feb 2016 00:13:18 +0100 Subject: [PATCH 2/2] WNOHANG is not supported on windows. --- osutils/reaper.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/osutils/reaper.go b/osutils/reaper.go index 973e417..f8106b0 100644 --- a/osutils/reaper.go +++ b/osutils/reaper.go @@ -1,3 +1,5 @@ +// +build !windows + package osutils import (