github.com/LazyboyChen7/engine@v17.12.1-ce-rc2+incompatible/libcontainerd/remote_daemon_process.go (about) 1 // +build !windows 2 3 package libcontainerd 4 5 import "github.com/pkg/errors" 6 7 // process represents the state for the main container process or an exec. 8 type process struct { 9 // id is the logical name of the process 10 id string 11 12 // cid is the container id to which this process belongs 13 cid string 14 15 // pid is the identifier of the process 16 pid uint32 17 18 // io holds the io reader/writer associated with the process 19 io *IOPipe 20 21 // root is the state directory for the process 22 root string 23 } 24 25 func (p *process) ID() string { 26 return p.id 27 } 28 29 func (p *process) Pid() uint32 { 30 return p.pid 31 } 32 33 func (p *process) SetPid(pid uint32) error { 34 if p.pid != 0 { 35 return errors.Errorf("pid is already set to %d", pid) 36 } 37 38 p.pid = pid 39 return nil 40 } 41 42 func (p *process) IOPipe() *IOPipe { 43 return p.io 44 } 45 46 func (p *process) CloseIO() { 47 if p.io.Stdin != nil { 48 p.io.Stdin.Close() 49 } 50 if p.io.Stdout != nil { 51 p.io.Stdout.Close() 52 } 53 if p.io.Stderr != nil { 54 p.io.Stderr.Close() 55 } 56 }