vendor latest containers/psgo

Signed-off-by: Valentin Rothberg <vrothberg@suse.com>

Closes: #1162
Approved by: rhatdan
This commit is contained in:
Valentin Rothberg
2018-07-26 15:26:52 +02:00
committed by Atomic Bot
parent d9ae17400d
commit 159f7f179b
16 changed files with 979 additions and 636 deletions

View File

@ -0,0 +1,22 @@
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
}