Merge pull request #103 from docker/osutils

Use a better package name for utility functions
This commit is contained in:
Jaana Burcu Dogan 2016-02-16 15:20:41 -08:00
commit 4de168877b
5 changed files with 12 additions and 10 deletions

View file

@ -8,7 +8,7 @@ import (
"syscall" "syscall"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/containerd/util" "github.com/docker/containerd/osutils"
"github.com/docker/docker/pkg/term" "github.com/docker/docker/pkg/term"
) )
@ -32,7 +32,7 @@ func main() {
signals := make(chan os.Signal, 2048) signals := make(chan os.Signal, 2048)
signal.Notify(signals) signal.Notify(signals)
// set the shim as the subreaper for all orphaned processes created by the container // 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") logrus.WithField("error", err).Fatal("shim: set as subreaper")
} }
// open the exit pipe // open the exit pipe
@ -82,7 +82,7 @@ func main() {
logrus.WithField("signal", s).Debug("shim: received signal") logrus.WithField("signal", s).Debug("shim: received signal")
switch s { switch s {
case syscall.SIGCHLD: case syscall.SIGCHLD:
exits, err := util.Reap() exits, err := osutils.Reap()
if err != nil { if err != nil {
logrus.WithField("error", err).Error("shim: reaping child processes") logrus.WithField("error", err).Error("shim: reaping child processes")
} }

View file

@ -19,8 +19,8 @@ import (
"github.com/docker/containerd" "github.com/docker/containerd"
"github.com/docker/containerd/api/grpc/server" "github.com/docker/containerd/api/grpc/server"
"github.com/docker/containerd/api/grpc/types" "github.com/docker/containerd/api/grpc/types"
"github.com/docker/containerd/osutils"
"github.com/docker/containerd/supervisor" "github.com/docker/containerd/supervisor"
"github.com/docker/containerd/util"
"github.com/rcrowley/go-metrics" "github.com/rcrowley/go-metrics"
) )
@ -141,7 +141,7 @@ func processMetrics() {
// update number of goroutines // update number of goroutines
g.Update(int64(runtime.NumGoroutine())) g.Update(int64(runtime.NumGoroutine()))
// collect the number of open fds // collect the number of open fds
fds, err := util.GetOpenFds(os.Getpid()) fds, err := osutils.GetOpenFds(os.Getpid())
if err != nil { if err != nil {
logrus.WithField("error", err).Error("containerd: get open fd count") 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() { func reapProcesses() {
s := make(chan os.Signal, 2048) s := make(chan os.Signal, 2048)
signal.Notify(s, syscall.SIGCHLD) 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") logrus.WithField("error", err).Error("containerd: set subpreaper")
} }
for range s { for range s {
if _, err := util.Reap(); err != nil { if _, err := osutils.Reap(); err != nil {
logrus.WithField("error", err).Error("containerd: reap child processes") logrus.WithField("error", err).Error("containerd: reap child processes")
} }
} }

View file

@ -1,6 +1,6 @@
// +build !windows,!darwin // +build !windows,!darwin
package util package osutils
import ( import (
"io/ioutil" "io/ioutil"

View file

@ -1,7 +1,7 @@
// +build linux // +build linux
// http://man7.org/linux/man-pages/man2/prctl.2.html // http://man7.org/linux/man-pages/man2/prctl.2.html
package util package osutils
import ( import (
"syscall" "syscall"

View file

@ -1,4 +1,6 @@
package util // +build !windows
package osutils
import ( import (
"syscall" "syscall"