Add pid and stdio to process state

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-02-03 14:30:45 -08:00
parent 36eb83cb99
commit 01176f2d7f
8 changed files with 163 additions and 111 deletions

View file

@ -34,6 +34,10 @@ type Process interface {
Signal(os.Signal) error
// Container returns the container that the process belongs to
Container() Container
// Stdio of the container
Stdio() Stdio
// SystemPid is the pid on the system
SystemPid() int
}
func newProcess(root, id string, c *container, s specs.Process, stdio Stdio) (*process, error) {
@ -82,6 +86,9 @@ func loadProcess(root, id string, c *container, s *ProcessState) (*process, erro
Stderr: s.Stderr,
},
}
if _, err := p.getPid(); err != nil {
return nil, err
}
if _, err := p.ExitStatus(); err != nil {
if err == ErrProcessNotExited {
exit, err := getExitPipe(filepath.Join(root, ExitFile))
@ -131,6 +138,10 @@ func (p *process) Container() Container {
return p.container
}
func (p *process) SystemPid() int {
return p.pid
}
// ExitFD returns the fd of the exit pipe
func (p *process) ExitFD() int {
return int(p.exitPipe.Fd())
@ -169,6 +180,10 @@ func (p *process) Spec() specs.Process {
return p.spec
}
func (p *process) Stdio() Stdio {
return p.stdio
}
// Close closes any open files and/or resouces on the process
func (p *process) Close() error {
return p.exitPipe.Close()