From ab76a88d6bf94d309f74df0a0be2ad3d648cfe7c Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Tue, 3 Feb 2015 10:50:18 -0800 Subject: [PATCH] Remove Wait() on container interface Since we return the pid for the started process we do not need this method on the interface. Signed-off-by: Michael Crosby --- .gitignore | 1 + container.go | 10 +--------- linux_container.go | 10 ---------- nsinit/exec.go | 11 ++++++++--- 4 files changed, 10 insertions(+), 22 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..4c2914fc7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +nsinit/nsinit diff --git a/container.go b/container.go index bb6bce89f..9db1e297b 100644 --- a/container.go +++ b/container.go @@ -5,7 +5,6 @@ package libcontainer import ( "os" - "syscall" "github.com/docker/libcontainer/cgroups" "github.com/docker/libcontainer/configs" @@ -26,7 +25,7 @@ type Container interface { // Returns the ID of the container ID() string - // Returns the current statusof the container. + // Returns the current status of the container. // // errors: // Systemerror - System error. @@ -97,13 +96,6 @@ type Container interface { // Systemerror - System error. Signal(signal os.Signal) error - // Wait waits for the init process of the conatiner to die and returns it's exit status. - // - // errors: - // ContainerDestroyed - Container no longer exists, - // Systemerror - System error. - Wait() (exitStatus syscall.WaitStatus, err error) - // OOM returns a read-only channel signaling when the container receives an OOM notification. // // errors: diff --git a/linux_container.go b/linux_container.go index f684188c5..bf501c86a 100644 --- a/linux_container.go +++ b/linux_container.go @@ -295,16 +295,6 @@ func (c *linuxContainer) Signal(signal os.Signal) error { panic("not implemented") } -func (c *linuxContainer) Wait() (syscall.WaitStatus, error) { - var status syscall.WaitStatus - // TODO : close exec.Cmd pipes, fix in master - _, err := syscall.Wait4(c.state.InitPid, &status, 0, nil) - if err != nil { - return 0, newGenericError(err, SystemError) - } - return status, err -} - func (c *linuxContainer) OOM() (<-chan struct{}, error) { return NotifyOnOOM(c.state) } diff --git a/nsinit/exec.go b/nsinit/exec.go index f710a9b73..d12f3638b 100644 --- a/nsinit/exec.go +++ b/nsinit/exec.go @@ -94,17 +94,22 @@ func execAction(context *cli.Context) { Stderr: os.Stderr, } tty.attach(process) - if _, err := container.Start(process); err != nil { + pid, err := container.Start(process) + if err != nil { fatal(err) } - status, err := container.Wait() + proc, err := os.FindProcess(pid) + if err != nil { + fatal(err) + } + status, err := proc.Wait() if err != nil { fatal(err) } if err := container.Destroy(); err != nil { fatal(err) } - exit(status) + exit(status.Sys().(syscall.WaitStatus)) } func exit(status syscall.WaitStatus) {