Open stdin write side in shim

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2017-03-24 14:03:26 -07:00
parent 379bd95a3c
commit b1fcb1745f
4 changed files with 32 additions and 0 deletions

View file

@ -4,14 +4,17 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"os"
"path/filepath"
"sync"
"syscall"
"github.com/crosbymichael/console"
runc "github.com/crosbymichael/go-runc"
shimapi "github.com/docker/containerd/api/services/shim"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/tonistiigi/fifo"
)
type execProcess struct {
@ -22,6 +25,7 @@ type execProcess struct {
io runc.IO
status int
pid int
closers []io.Closer
parent *initProcess
}
@ -66,6 +70,13 @@ func newExecProcess(context context.Context, path string, r *shimapi.ExecRequest
if err := parent.runc.Exec(context, parent.id, spec, opts); err != nil {
return nil, err
}
if r.Stdin != "" {
sc, err := fifo.OpenFifo(context, r.Stdin, syscall.O_WRONLY|syscall.O_NONBLOCK, 0)
if err != nil {
return nil, err
}
e.closers = append(e.closers, sc)
}
if socket != nil {
console, err := socket.ReceiveMaster()
if err != nil {
@ -111,6 +122,9 @@ func (e *execProcess) Exited(status int) {
e.status = status
e.Wait()
if e.io != nil {
for _, c := range e.closers {
c.Close()
}
e.io.Close()
}
}