Add rough container type and runc runtime

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-09-28 15:09:22 -07:00
parent c2da97c4d1
commit b3ab74fee3
5 changed files with 545 additions and 0 deletions

60
process.go Normal file
View file

@ -0,0 +1,60 @@
package containerkit
import (
"errors"
"io"
"os"
specs "github.com/opencontainers/runtime-spec/specs-go"
)
var (
ErrNotExecProcess = errors.New("containerkit: process not an exec process")
)
type ProcessDelegate interface {
Pid() int
Wait() (uint32, error)
Signal(os.Signal) error
}
type Process struct {
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
exec bool
s *specs.Process
driver ExecutionDriver
c *Container
d ProcessDelegate
}
func (p *Process) Spec() *specs.Process {
return p.s
}
func (p *Process) Start() error {
if !p.exec {
return ErrNotExecProcess
}
d, err := p.driver.Exec(p.c, p)
if err != nil {
return err
}
p.d = d
return nil
}
func (p *Process) Pid() int {
return p.d.Pid()
}
func (p *Process) Wait() (uint32, error) {
return p.d.Wait()
}
func (p *Process) Signal(s os.Signal) error {
return p.d.Signal(s)
}