[bin] Replace syscall with /x/sys/unix
Replace syscall usage with /sys/unix in the binaries and their packages Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
4f7d521510
commit
3db1ea8d07
8 changed files with 40 additions and 36 deletions
20
sys/epoll.go
20
sys/epoll.go
|
@ -2,21 +2,19 @@
|
|||
|
||||
package sys
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// EpollCreate1 directly calls syscall.EpollCreate1
|
||||
// EpollCreate1 directly calls unix.EpollCreate1
|
||||
func EpollCreate1(flag int) (int, error) {
|
||||
return syscall.EpollCreate1(flag)
|
||||
return unix.EpollCreate1(flag)
|
||||
}
|
||||
|
||||
// EpollCtl directly calls syscall.EpollCtl
|
||||
func EpollCtl(epfd int, op int, fd int, event *syscall.EpollEvent) error {
|
||||
return syscall.EpollCtl(epfd, op, fd, event)
|
||||
// EpollCtl directly calls unix.EpollCtl
|
||||
func EpollCtl(epfd int, op int, fd int, event *unix.EpollEvent) error {
|
||||
return unix.EpollCtl(epfd, op, fd, event)
|
||||
}
|
||||
|
||||
// EpollWait directly calls syscall.EpollWait
|
||||
func EpollWait(epfd int, events []syscall.EpollEvent, msec int) (int, error) {
|
||||
return syscall.EpollWait(epfd, events, msec)
|
||||
// EpollWait directly calls unix.EpollWait
|
||||
func EpollWait(epfd int, events []unix.EpollEvent, msec int) (int, error) {
|
||||
return unix.EpollWait(epfd, events, msec)
|
||||
}
|
||||
|
|
|
@ -36,8 +36,9 @@ import "C"
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// EpollCreate1 calls a C implementation
|
||||
|
@ -50,8 +51,8 @@ func EpollCreate1(flag int) (int, error) {
|
|||
}
|
||||
|
||||
// EpollCtl calls a C implementation
|
||||
func EpollCtl(epfd int, op int, fd int, event *syscall.EpollEvent) error {
|
||||
errno := C.EpollCtl(C.int(epfd), C.int(syscall.EPOLL_CTL_ADD), C.int(fd), C.int(event.Events), C.int(event.Fd))
|
||||
func EpollCtl(epfd int, op int, fd int, event *unix.EpollEvent) error {
|
||||
errno := C.EpollCtl(C.int(epfd), C.int(unix.EPOLL_CTL_ADD), C.int(fd), C.int(event.Events), C.int(event.Fd))
|
||||
if errno < 0 {
|
||||
return fmt.Errorf("Failed to ctl epoll")
|
||||
}
|
||||
|
@ -59,7 +60,7 @@ func EpollCtl(epfd int, op int, fd int, event *syscall.EpollEvent) error {
|
|||
}
|
||||
|
||||
// EpollWait calls a C implementation
|
||||
func EpollWait(epfd int, events []syscall.EpollEvent, msec int) (int, error) {
|
||||
func EpollWait(epfd int, events []unix.EpollEvent, msec int) (int, error) {
|
||||
var c_events [128]C.struct_event_t
|
||||
n := int(C.run_epoll_wait(C.int(epfd), (*C.struct_event_t)(unsafe.Pointer(&c_events))))
|
||||
if n < 0 {
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
package sys
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// PR_SET_CHILD_SUBREAPER allows setting the child subreaper.
|
||||
|
@ -33,7 +34,7 @@ const prGetChildSubreaper = 37
|
|||
// GetSubreaper returns the subreaper setting for the calling process
|
||||
func GetSubreaper() (int, error) {
|
||||
var i uintptr
|
||||
if _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, prGetChildSubreaper, uintptr(unsafe.Pointer(&i)), 0); err != 0 {
|
||||
if _, _, err := unix.RawSyscall(unix.SYS_PRCTL, prGetChildSubreaper, uintptr(unsafe.Pointer(&i)), 0); err != 0 {
|
||||
return -1, err
|
||||
}
|
||||
return int(i), nil
|
||||
|
@ -41,7 +42,7 @@ func GetSubreaper() (int, error) {
|
|||
|
||||
// SetSubreaper sets the value i as the subreaper setting for the calling process
|
||||
func SetSubreaper(i int) error {
|
||||
if _, _, err := syscall.RawSyscall(syscall.SYS_PRCTL, prSetChildSubreaper, uintptr(i), 0); err != 0 {
|
||||
if _, _, err := unix.RawSyscall(unix.SYS_PRCTL, prSetChildSubreaper, uintptr(i), 0); err != 0 {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
package sys
|
||||
|
||||
import "syscall"
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// Exit is the wait4 information from an exited process
|
||||
type Exit struct {
|
||||
|
@ -14,17 +14,17 @@ type Exit struct {
|
|||
// exit information
|
||||
func Reap(wait bool) (exits []Exit, err error) {
|
||||
var (
|
||||
ws syscall.WaitStatus
|
||||
rus syscall.Rusage
|
||||
ws unix.WaitStatus
|
||||
rus unix.Rusage
|
||||
)
|
||||
flag := syscall.WNOHANG
|
||||
flag := unix.WNOHANG
|
||||
if wait {
|
||||
flag = 0
|
||||
}
|
||||
for {
|
||||
pid, err := syscall.Wait4(-1, &ws, flag, &rus)
|
||||
pid, err := unix.Wait4(-1, &ws, flag, &rus)
|
||||
if err != nil {
|
||||
if err == syscall.ECHILD {
|
||||
if err == unix.ECHILD {
|
||||
return exits, nil
|
||||
}
|
||||
return exits, err
|
||||
|
@ -43,7 +43,7 @@ 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 {
|
||||
func exitStatus(status unix.WaitStatus) int {
|
||||
if status.Signaled() {
|
||||
return exitSignalOffset + int(status.Signal())
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ import (
|
|||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// CreateUnixSocket creates a unix socket and returns the listener
|
||||
|
@ -14,7 +15,7 @@ func CreateUnixSocket(path string) (net.Listener, error) {
|
|||
if err := os.MkdirAll(filepath.Dir(path), 0660); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := syscall.Unlink(path); err != nil && !os.IsNotExist(err) {
|
||||
if err := unix.Unlink(path); err != nil && !os.IsNotExist(err) {
|
||||
return nil, err
|
||||
}
|
||||
return net.Listen("unix", path)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue