Tizen_4.0 base
[platform/upstream/docker-engine.git] / vendor / github.com / containerd / containerd / runtime / process_solaris.go
1 // +build solaris
2
3 package runtime
4
5 import (
6         "bytes"
7         "encoding/json"
8         "fmt"
9         "os/exec"
10
11         runtimespec "github.com/opencontainers/runtime-spec/specs-go"
12 )
13
14 // On Solaris we already have a state file maintained by the framework.
15 // This is read by runz state. We just call that instead of maintaining
16 // a separate file.
17 func (p *process) getPidFromFile() (int, error) {
18         //we get this information from runz state
19         cmd := exec.Command("runc", "state", p.container.ID())
20         outBuf, errBuf := new(bytes.Buffer), new(bytes.Buffer)
21         cmd.Stdout, cmd.Stderr = outBuf, errBuf
22
23         if err := cmd.Run(); err != nil {
24                 // TODO: Improve logic
25                 return -1, errContainerNotFound
26         }
27         response := runtimespec.State{}
28         decoder := json.NewDecoder(outBuf)
29         if err := decoder.Decode(&response); err != nil {
30                 return -1, fmt.Errorf("unable to decode json response: %+v", err)
31         }
32         p.pid = response.Pid
33         return p.pid, nil
34 }