Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for fork exec to get real process details #440

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pkg/processmanager/v1/process_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
const (
cleanupInterval = 1 * time.Minute
maxTreeDepth = 50
runCCommPrefix = "runc:["
)

type ProcessManager struct {
Expand Down Expand Up @@ -275,6 +276,20 @@ func (p *ProcessManager) GetProcessTreeForPID(containerID string, pid int) (apit
}
}

// If the process is runc, try to fetch the real process info.
// Intentionally we are doing this only once the process is asked for to avoid unnecessary calls to /proc and give time for the process to be created.
if strings.HasPrefix(result.Comm, runCCommPrefix) {
if process, err := p.getProcessFromProc(int(result.PID)); err == nil {
childerns := result.Children
upperLayer := result.UpperLayer
result = process
result.Children = childerns
result.UpperLayer = upperLayer
// Update the process in the tree
p.processTree.Set(result.PID, result)
}
}

return result, nil
}

Expand Down
Loading