Add exec support to client

This also fixes a deadlock in the shim's reaper where execs would lockup
and/or miss a quick exiting exec process's exit status.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby
2017-05-31 10:40:45 -07:00
parent f55f40eeec
commit ebf935d990
5 changed files with 234 additions and 14 deletions

24
task.go
View File

@@ -6,6 +6,7 @@ import (
"github.com/containerd/containerd/api/services/execution"
taskapi "github.com/containerd/containerd/api/types/task"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
const UnknownExitStatus = 255
@@ -21,14 +22,22 @@ const (
)
type Task interface {
Pid() uint32
Delete(context.Context) (uint32, error)
Kill(context.Context, syscall.Signal) error
Pause(context.Context) error
Resume(context.Context) error
Pid() uint32
Start(context.Context) error
Status(context.Context) (TaskStatus, error)
Wait(context.Context) (uint32, error)
Exec(context.Context, *specs.Process, IOCreation) (Process, error)
}
type Process interface {
Pid() uint32
Start(context.Context) error
Kill(context.Context, syscall.Signal) error
Wait(context.Context) (uint32, error)
}
var _ = (Task)(&task{})
@@ -121,3 +130,16 @@ func (t *task) Delete(ctx context.Context) (uint32, error) {
}
return r.ExitStatus, cerr
}
func (t *task) Exec(ctx context.Context, spec *specs.Process, ioCreate IOCreation) (Process, error) {
i, err := ioCreate()
if err != nil {
return nil, err
}
return &process{
task: t,
io: i,
spec: spec,
pidSync: make(chan struct{}),
}, nil
}