mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-08-29 03:37:54 +00:00
22 lines
438 B
Go
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
|
|
}
|