mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add ppid to trace procfs output.
Updates #4805 PiperOrigin-RevId: 452169866
This commit is contained in:
@@ -49,6 +49,7 @@ type UIDGID struct {
|
||||
type Status struct {
|
||||
Comm string `json:"comm,omitempty"`
|
||||
PID int32 `json:"pid,omitempty"`
|
||||
PPID int32 `json:"ppid,omitempty"`
|
||||
UID UIDGID `json:"uid,omitempty"`
|
||||
GID UIDGID `json:"gid,omitempty"`
|
||||
VMSize uint64 `json:"vm_size,omitempty"`
|
||||
@@ -208,12 +209,17 @@ func getFDLimit(ctx context.Context, pid kernel.ThreadID) (limits.Limit, error)
|
||||
return limits.Limit{}, fmt.Errorf("could not find limit set for pid %s", pid)
|
||||
}
|
||||
|
||||
func getStatus(t *kernel.Task, mm *mm.MemoryManager, pid kernel.ThreadID) Status {
|
||||
func getStatus(t *kernel.Task, mm *mm.MemoryManager, pid kernel.ThreadID, pidns *kernel.PIDNamespace) Status {
|
||||
creds := t.Credentials()
|
||||
uns := creds.UserNamespace
|
||||
ppid := kernel.ThreadID(0)
|
||||
if parent := t.Parent(); parent != nil {
|
||||
ppid = pidns.IDOfThreadGroup(parent.ThreadGroup())
|
||||
}
|
||||
return Status{
|
||||
Comm: t.Name(),
|
||||
PID: int32(pid),
|
||||
PPID: int32(ppid),
|
||||
UID: UIDGID{
|
||||
Real: uint32(creds.RealKUID.In(uns).OrOverflow()),
|
||||
Effective: uint32(creds.EffectiveKUID.In(uns).OrOverflow()),
|
||||
@@ -265,7 +271,7 @@ func Dump(t *kernel.Task, pid kernel.ThreadID, pidns *kernel.PIDNamespace) (Proc
|
||||
// We don't need to worry about fake cgroup controllers as that is not
|
||||
// supported in runsc.
|
||||
Cgroup: t.GetCgroupEntries(),
|
||||
Status: getStatus(t, mm, pid),
|
||||
Status: getStatus(t, mm, pid, pidns),
|
||||
Stat: getStat(t, pid, pidns),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -413,6 +413,10 @@ func TestProcfsDump(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
if wantPPID := int32(0); procfsDump[0].Status.PPID != wantPPID {
|
||||
t.Errorf("expected PPID to be %d, but got %d", wantPPID, procfsDump[0].Status.PPID)
|
||||
}
|
||||
|
||||
if wantName := "sleep"; procfsDump[0].Status.Comm != wantName {
|
||||
t.Errorf("expected Comm to be %q, but got %q", wantName, procfsDump[0].Status.Comm)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user