9 "github.com/opencontainers/runc/libcontainer/system"
12 func newRestoredProcess(pid int, fds []string) (*restoredProcess, error) {
16 proc, err := os.FindProcess(pid)
20 started, err := system.GetProcessStartTime(pid)
24 return &restoredProcess{
26 processStartTime: started,
31 type restoredProcess struct {
33 processStartTime string
37 func (p *restoredProcess) start() error {
38 return newGenericError(fmt.Errorf("restored process cannot be started"), SystemError)
41 func (p *restoredProcess) pid() int {
45 func (p *restoredProcess) terminate() error {
47 if _, werr := p.wait(); err == nil {
53 func (p *restoredProcess) wait() (*os.ProcessState, error) {
54 // TODO: how do we wait on the actual process?
55 // maybe use --exec-cmd in criu
56 st, err := p.proc.Wait()
63 func (p *restoredProcess) startTime() (string, error) {
64 return p.processStartTime, nil
67 func (p *restoredProcess) signal(s os.Signal) error {
68 return p.proc.Signal(s)
71 func (p *restoredProcess) externalDescriptors() []string {
75 func (p *restoredProcess) setExternalDescriptors(newFds []string) {
79 // nonChildProcess represents a process where the calling process is not
80 // the parent process. This process is created when a factory loads a container from
82 type nonChildProcess struct {
84 processStartTime string
88 func (p *nonChildProcess) start() error {
89 return newGenericError(fmt.Errorf("restored process cannot be started"), SystemError)
92 func (p *nonChildProcess) pid() int {
96 func (p *nonChildProcess) terminate() error {
97 return newGenericError(fmt.Errorf("restored process cannot be terminated"), SystemError)
100 func (p *nonChildProcess) wait() (*os.ProcessState, error) {
101 return nil, newGenericError(fmt.Errorf("restored process cannot be waited on"), SystemError)
104 func (p *nonChildProcess) startTime() (string, error) {
105 return p.processStartTime, nil
108 func (p *nonChildProcess) signal(s os.Signal) error {
109 proc, err := os.FindProcess(p.processPid)
113 return proc.Signal(s)
116 func (p *nonChildProcess) externalDescriptors() []string {
120 func (p *nonChildProcess) setExternalDescriptors(newFds []string) {