Move libcontainer to x/sys/unix

Since syscall is outdated and broken for some architectures,
use x/sys/unix instead.

There are still some dependencies on the syscall package that will
remain in syscall for the forseeable future:

Errno
Signal
SysProcAttr

Additionally:
- os still uses syscall, so it needs to be kept for anything
returning *os.ProcessState, such as process.Wait.

Signed-off-by: Christy Perez <christy@linux.vnet.ibm.com>
This commit is contained in:
Christy Perez
2017-05-09 17:38:27 -04:00
parent 639454475c
commit 3d7cb4293c
33 changed files with 292 additions and 300 deletions
+3 -2
View File
@@ -8,8 +8,9 @@ import (
"os"
"path/filepath"
"strings"
"syscall"
"unsafe"
"golang.org/x/sys/unix"
)
const (
@@ -41,7 +42,7 @@ func ResolveRootfs(uncleanRootfs string) (string, error) {
// ExitStatus returns the correct exit status for a process based on if it
// was signaled or exited cleanly
func ExitStatus(status syscall.WaitStatus) int {
func ExitStatus(status unix.WaitStatus) int {
if status.Signaled() {
return exitSignalOffset + int(status.Signal())
}
+4 -3
View File
@@ -5,8 +5,9 @@ import (
"fmt"
"os"
"path/filepath"
"syscall"
"testing"
"golang.org/x/sys/unix"
)
func TestGenerateName(t *testing.T) {
@@ -94,7 +95,7 @@ func TestResolveRootfsWithNonExistingDir(t *testing.T) {
}
func TestExitStatus(t *testing.T) {
status := syscall.WaitStatus(0)
status := unix.WaitStatus(0)
ex := ExitStatus(status)
if ex != 0 {
t.Errorf("expected exit status to equal 0 and received %d", ex)
@@ -102,7 +103,7 @@ func TestExitStatus(t *testing.T) {
}
func TestExitStatusSignaled(t *testing.T) {
status := syscall.WaitStatus(2)
status := unix.WaitStatus(2)
ex := ExitStatus(status)
if ex != 130 {
t.Errorf("expected exit status to equal 130 and received %d", ex)
+5 -4
View File
@@ -6,7 +6,8 @@ import (
"io/ioutil"
"os"
"strconv"
"syscall"
"golang.org/x/sys/unix"
)
func CloseExecFrom(minFd int) error {
@@ -26,8 +27,8 @@ func CloseExecFrom(minFd int) error {
continue
}
// intentionally ignore errors from syscall.CloseOnExec
syscall.CloseOnExec(fd)
// intentionally ignore errors from unix.CloseOnExec
unix.CloseOnExec(fd)
// the cases where this might fail are basically file descriptors that have already been closed (including and especially the one that was created when ioutil.ReadDir did the "opendir" syscall)
}
return nil
@@ -35,7 +36,7 @@ func CloseExecFrom(minFd int) error {
// NewSockPair returns a new unix socket pair
func NewSockPair(name string) (parent *os.File, child *os.File, err error) {
fds, err := syscall.Socketpair(syscall.AF_LOCAL, syscall.SOCK_STREAM|syscall.SOCK_CLOEXEC, 0)
fds, err := unix.Socketpair(unix.AF_LOCAL, unix.SOCK_STREAM|unix.SOCK_CLOEXEC, 0)
if err != nil {
return nil, nil, err
}