containerd/execution/executors/oci/process.go
Kenfe-Mickael Laventure 7dd69a8597 execution: use provided process ID for state
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-12-16 08:49:09 -08:00

51 lines
875 B
Go

package oci
import (
"os"
"syscall"
"github.com/docker/containerd/execution"
)
func newProcess(c *execution.Container, id string, pid int) (execution.Process, error) {
proc, err := os.FindProcess(pid)
if err != nil {
return nil, err
}
return &process{
c: c,
id: id,
proc: proc,
}, nil
}
type process struct {
c *execution.Container
id string
proc *os.Process
}
func (p *process) Container() *execution.Container {
return p.c
}
func (p *process) ID() string {
return p.id
}
func (p *process) Pid() int64 {
return int64(p.proc.Pid)
}
func (p *process) Wait() (uint32, error) {
state, err := p.proc.Wait()
if err != nil {
return 0, nil
}
// TODO: implement kill-all if we are the init pid
return uint32(state.Sys().(syscall.WaitStatus).ExitStatus()), nil
}
func (p *process) Signal(s os.Signal) error {
return p.proc.Signal(s)
}