[exec] Replace syscall with /x/sys/unix
This replaces the syscall usage with sys/unix in the execution code Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
parent
4f33aa2b5c
commit
4f7d521510
6 changed files with 43 additions and 37 deletions
|
@ -9,7 +9,6 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
|
@ -21,6 +20,7 @@ import (
|
|||
runc "github.com/crosbymichael/go-runc"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -249,9 +249,9 @@ func (r *Runtime) killContainer(ctx context.Context, id string) {
|
|||
// TODO: get Command provided for initial container creation
|
||||
// Command: r.Runtime,
|
||||
LogFormat: runc.JSON,
|
||||
PdeathSignal: syscall.SIGKILL,
|
||||
PdeathSignal: unix.SIGKILL,
|
||||
}
|
||||
if err := runtime.Kill(ctx, id, int(syscall.SIGKILL), &runc.KillOpts{
|
||||
if err := runtime.Kill(ctx, id, int(unix.SIGKILL), &runc.KillOpts{
|
||||
All: true,
|
||||
}); err != nil {
|
||||
log.G(ctx).WithError(err).Warnf("kill all processes for %s", id)
|
||||
|
@ -271,7 +271,7 @@ func (r *Runtime) killContainer(ctx context.Context, id string) {
|
|||
log.G(ctx).WithError(err).Warnf("delete container %s", id)
|
||||
}
|
||||
// try to unmount the rootfs is it was not held by an external shim
|
||||
syscall.Unmount(filepath.Join(r.root, id, "rootfs"), 0)
|
||||
unix.Unmount(filepath.Join(r.root, id, "rootfs"), 0)
|
||||
// remove container bundle
|
||||
if err := r.deleteBundle(id); err != nil {
|
||||
log.G(ctx).WithError(err).Warnf("delete container bundle %s", id)
|
||||
|
|
|
@ -2,12 +2,12 @@ package shim
|
|||
|
||||
import (
|
||||
"path/filepath"
|
||||
"syscall"
|
||||
|
||||
shimapi "github.com/containerd/containerd/api/services/shim"
|
||||
"github.com/containerd/containerd/api/types/container"
|
||||
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/sys/unix"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
@ -68,7 +68,7 @@ func (c *client) Kill(ctx context.Context, in *shimapi.KillRequest, opts ...grpc
|
|||
func (c *client) Exit(ctx context.Context, in *shimapi.ExitRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error) {
|
||||
// don't exit the calling process for the client
|
||||
// but make sure we unmount the containers rootfs for this client
|
||||
if err := syscall.Unmount(filepath.Join(c.s.path, "rootfs"), 0); err != nil {
|
||||
if err := unix.Unmount(filepath.Join(c.s.path, "rootfs"), 0); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return empty, nil
|
||||
|
|
|
@ -12,6 +12,8 @@ import (
|
|||
"sync"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
shimapi "github.com/containerd/containerd/api/services/shim"
|
||||
"github.com/crosbymichael/console"
|
||||
runc "github.com/crosbymichael/go-runc"
|
||||
|
@ -145,7 +147,7 @@ func (e *execProcess) Resize(ws console.WinSize) error {
|
|||
}
|
||||
|
||||
func (e *execProcess) Signal(sig int) error {
|
||||
return syscall.Kill(e.pid, syscall.Signal(sig))
|
||||
return unix.Kill(e.pid, syscall.Signal(sig))
|
||||
}
|
||||
|
||||
func (e *execProcess) Stdin() io.Closer {
|
||||
|
|
|
@ -10,6 +10,8 @@ import (
|
|||
"sync"
|
||||
"syscall"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
shimapi "github.com/containerd/containerd/api/services/shim"
|
||||
"github.com/crosbymichael/console"
|
||||
|
@ -175,7 +177,7 @@ func (p *initProcess) killAll(context context.Context) error {
|
|||
}
|
||||
|
||||
func (p *initProcess) Signal(sig int) error {
|
||||
return syscall.Kill(p.pid, syscall.Signal(sig))
|
||||
return unix.Kill(p.pid, syscall.Signal(sig))
|
||||
}
|
||||
|
||||
func (p *initProcess) Stdin() io.Closer {
|
||||
|
|
|
@ -15,6 +15,7 @@ import (
|
|||
google_protobuf "github.com/golang/protobuf/ptypes/empty"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var empty = &google_protobuf.Empty{}
|
||||
|
@ -180,7 +181,7 @@ func (s *Service) State(ctx context.Context, r *shimapi.StateRequest) (*shimapi.
|
|||
defer s.mu.Unlock()
|
||||
for _, p := range s.processes {
|
||||
status := container.Status_RUNNING
|
||||
if err := syscall.Kill(p.Pid(), 0); err != nil {
|
||||
if err := unix.Kill(p.Pid(), 0); err != nil {
|
||||
if err != syscall.ESRCH {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -210,7 +211,7 @@ func (s *Service) Resume(ctx context.Context, r *shimapi.ResumeRequest) (*google
|
|||
|
||||
func (s *Service) Exit(ctx context.Context, r *shimapi.ExitRequest) (*google_protobuf.Empty, error) {
|
||||
// signal ourself to exit
|
||||
if err := syscall.Kill(os.Getpid(), syscall.SIGTERM); err != nil {
|
||||
if err := unix.Kill(os.Getpid(), syscall.SIGTERM); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return empty, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue