containerd/vendor/github.com/crosbymichael/go-runc/utils.go
Michael Crosby 4fd2478513 Update go-runc to bd9aef7cf4402a3a8728e3ef83dcca6a5a1be899
Also remove the comment fields in the vndr script, they are too hard to
keep up to date and add little value when we have the git commit
timestamps

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-03-09 13:47:49 -08:00

28 lines
644 B
Go

package runc
import (
"io/ioutil"
"strconv"
"syscall"
)
// ReadPidFile reads the pid file at the provided path and returns
// the pid or an error if the read and conversion is unsuccessful
func ReadPidFile(path string) (int, error) {
data, err := ioutil.ReadFile(path)
if err != nil {
return -1, err
}
return strconv.Atoi(string(data))
}
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()
}