github.com/zhuohuang-hust/src-cbuild@v0.0.0-20230105071821-c7aab3e7c840/mergeCode/containerd/runtime/container_solaris.go (about) 1 package runtime 2 3 import ( 4 "bytes" 5 "encoding/json" 6 "fmt" 7 "os/exec" 8 "strings" 9 10 "github.com/docker/containerd/specs" 11 ocs "github.com/opencontainers/runtime-spec/specs-go" 12 ) 13 14 func getRootIDs(s *specs.Spec) (int, int, error) { 15 return 0, 0, nil 16 } 17 18 func (c *container) OOM() (OOM, error) { 19 return nil, nil 20 } 21 22 func (c *container) Pids() ([]int, error) { 23 var pids []int 24 25 // TODO: This could be racy. Needs more investigation. 26 //we get this information from runz state 27 cmd := exec.Command(c.runtime, "state", c.id) 28 outBuf, errBuf := new(bytes.Buffer), new(bytes.Buffer) 29 cmd.Stdout, cmd.Stderr = outBuf, errBuf 30 31 if err := cmd.Run(); err != nil { 32 if strings.Contains(errBuf.String(), "Container not found") { 33 return nil, errContainerNotFound 34 } 35 return nil, fmt.Errorf("Error is: %+v\n", err) 36 } 37 response := ocs.State{} 38 decoder := json.NewDecoder(outBuf) 39 if err := decoder.Decode(&response); err != nil { 40 return nil, fmt.Errorf("unable to decode json response: %+v", err) 41 } 42 pids = append(pids, response.Pid) 43 return pids, nil 44 } 45 46 func (c *container) UpdateResources(r *Resource) error { 47 return nil 48 }