Add working shim exec driver for start

Still need to implement a working Wait() on the process using epoll
because of the non-blocking exit fifo

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-10-06 11:39:12 -07:00
parent c76f883ccd
commit 90e4f130c8
6 changed files with 223 additions and 76 deletions

View file

@ -69,12 +69,12 @@ func start(log *os.File) error {
// open the exit pipe
f, err := os.OpenFile("exit", syscall.O_WRONLY, 0)
if err != nil {
return err
return fmt.Errorf("open exit fifo %s", err)
}
defer f.Close()
control, err := os.OpenFile("control", syscall.O_RDWR, 0)
if err != nil {
return err
return fmt.Errorf("open control fifo %s", err)
}
defer control.Close()
p, err := newProcess(flag.Arg(0), flag.Arg(1), flag.Arg(2))
@ -150,7 +150,7 @@ func start(log *os.File) error {
term.SetWinsize(p.console.Fd(), &ws)
case 2:
// signal
if err := syscall.Kill(p.pid(), msg.Width); err != nil {
if err := syscall.Kill(p.pid(), syscall.Signal(msg.Width)); err != nil {
writeMessage(log, "warn", err)
}
}

View file

@ -39,9 +39,9 @@ type checkpoint struct {
type processState struct {
specs.ProcessSpec
Exec bool `json:"exec"`
Stdin string `json:"containerdStdin"`
Stdout string `json:"containerdStdout"`
Stderr string `json:"containerdStderr"`
Stdin string `json:"stdin"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
RuntimeArgs []string `json:"runtimeArgs"`
NoPivotRoot bool `json:"noPivotRoot"`
CheckpointPath string `json:"checkpoint"`
@ -74,7 +74,7 @@ func newProcess(id, bundle, runtimeName string) (*process, error) {
}
s, err := loadProcess()
if err != nil {
return nil, err
return nil, fmt.Errorf("load process from json %s", err)
}
p.state = s
if s.CheckpointPath != "" {
@ -86,7 +86,7 @@ func newProcess(id, bundle, runtimeName string) (*process, error) {
p.checkpointPath = s.CheckpointPath
}
if err := p.openIO(); err != nil {
return nil, err
return nil, fmt.Errorf("open IO for container %s", err)
}
return p, nil
}