1
0
mirror of https://github.com/google/gops.git synced 2024-11-24 08:22:25 +02:00

add PPID to the output

This commit is contained in:
Jaana Burcu Dogan 2017-09-04 18:49:17 -07:00
parent 08cb2394b4
commit f0a29dc244

View File

@ -68,9 +68,10 @@ func main() {
func processes() {
ps := goprocess.FindAll()
var maxPID, maxExec, maxVersion int
var maxPID, maxPPID, maxExec, maxVersion int
for _, p := range ps {
maxPID = max(maxPID, len(strconv.Itoa(p.PID)))
maxPPID = max(maxPPID, len(strconv.Itoa(p.PPID)))
maxExec = max(maxExec, len(p.Exec))
maxVersion = max(maxVersion, len(p.BuildVersion))
}
@ -79,6 +80,9 @@ func processes() {
buf := bytes.NewBuffer(nil)
pid := strconv.Itoa(p.PID)
fmt.Fprint(buf, pad(pid, maxPID))
fmt.Fprint(buf, " ")
ppid := strconv.Itoa(p.PPID)
fmt.Fprint(buf, pad(ppid, maxPPID))
if p.Agent {
fmt.Fprint(buf, "*")
} else {