spiegel_podman/vendor/github.com/containers/psgo/internal/proc/cmdline.go
Valentin Rothberg 159f7f179b vendor latest containers/psgo
Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1162
Approved by: rhatdan
2018-07-26 17:01:40 +00:00

22 lines
438 B
Go

package proc
import (
"bytes"
"fmt"
"io/ioutil"
)
// ParseCmdLine parses a /proc/$pid/cmdline file and returns a string slice.
func ParseCmdLine(pid string) ([]string, error) {
data, err := ioutil.ReadFile(fmt.Sprintf("/proc/%s/cmdline", pid))
if err != nil {
return nil, err
}
cmdLine := []string{}
for _, rawCmd := range bytes.Split(data, []byte{0}) {
cmdLine = append(cmdLine, string(rawCmd))
}
return cmdLine, nil
}