Update shim for exec

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-02-01 11:02:41 -08:00
parent 6808dbc02f
commit 835f3b6a97
37 changed files with 786 additions and 709 deletions

View file

@ -1,6 +1,8 @@
package runtime
import (
"encoding/json"
"io"
"io/ioutil"
"os"
"path/filepath"
@ -10,6 +12,31 @@ import (
"github.com/opencontainers/specs"
)
type Process interface {
io.Closer
// ID of the process.
// This is either "init" when it is the container's init process or
// it is a user provided id for the process similar to the container id
ID() string
// Stdin returns the path the the processes stdin fifo
Stdin() string
// Stdout returns the path the the processes stdout fifo
Stdout() string
// Stderr returns the path the the processes stderr fifo
Stderr() string
// ExitFD returns the fd the provides an event when the process exits
ExitFD() int
// ExitStatus returns the exit status of the process or an error if it
// has not exited
ExitStatus() (int, error)
Spec() specs.Process
// Signal sends the provided signal to the process
Signal(os.Signal) error
// Container returns the container that the process belongs to
Container() Container
}
func newProcess(root, id string, c *container, s specs.Process) (*process, error) {
p := &process{
root: root,
@ -17,6 +44,14 @@ func newProcess(root, id string, c *container, s specs.Process) (*process, error
container: c,
spec: s,
}
f, err := os.Create(filepath.Join(root, "process.json"))
if err != nil {
return nil, err
}
defer f.Close()
if err := json.NewEncoder(f).Encode(s); err != nil {
return nil, err
}
// create fifo's for the process
for name, fd := range map[string]*string{
"stdin": &p.stdin,
@ -58,7 +93,7 @@ func loadProcess(root, id string, c *container, s specs.Process) (*process, erro
}
return nil, err
}
return nil, ErrProcessExited
return p, nil
}
func getExitPipe(path string) (*os.File, error) {