Remove dep on larger packages

This removes most of the deps on the larger packages for the shim and
reduces the binary size and memory footprint from a 7.1mb binary to a
2.6mb binary.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-04-04 11:23:40 -07:00
parent 96034177f9
commit 6f18acda73
5 changed files with 122 additions and 41 deletions

View file

@ -2,11 +2,7 @@
package osutils
import (
"syscall"
"github.com/opencontainers/runc/libcontainer/utils"
)
import "syscall"
// Exit is the wait4 information from an exited process
type Exit struct {
@ -34,7 +30,18 @@ func Reap() (exits []Exit, err error) {
}
exits = append(exits, Exit{
Pid: pid,
Status: utils.ExitStatus(ws),
Status: exitStatus(ws),
})
}
}
const exitSignalOffset = 128
// exitStatus returns the correct exit status for a process based on if it
// was signaled or exited cleanly
func exitStatus(status syscall.WaitStatus) int {
if status.Signaled() {
return exitSignalOffset + int(status.Signal())
}
return status.ExitStatus()
}