Skip to content

Commit

Permalink
Adding pcomm
Browse files Browse the repository at this point in the history
Signed-off-by: Amit Schendel <[email protected]>
  • Loading branch information
amitschendel committed Oct 31, 2024
1 parent 3a650e4 commit 9fa19fd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions pkg/processmanager/v1/process_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,29 @@ func getProcessFromProc(pid int) (apitypes.Process, error) {

cwd, _ := proc.Cwd()
path, _ := proc.Executable()
pcomm := func() string {
if stat.PPID <= 0 {
return ""
}

parentProc, err := procfs.NewProc(stat.PPID)
if err != nil {
return ""
}

parentStat, err := parentProc.Stat()
if err != nil {
return ""
}

return parentStat.Comm
}()

return apitypes.Process{
PID: uint32(pid),
PPID: uint32(stat.PPID),
Comm: stat.Comm,
Pcomm: pcomm,
Uid: &uid,
Gid: &gid,
Cmdline: strings.Join(cmdline, " "),
Expand Down

0 comments on commit 9fa19fd

Please sign in to comment.