mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Return correct parent PID
Old code was returning ID of the thread that created the child process. It should be returning the ID of the parent process instead. PiperOrigin-RevId: 214720910 Change-Id: I95715c535bcf468ecf1ae771cccd04a4cd345b36
This commit is contained in:
committed by
Shentubot
parent
a003e041c8
commit
fca9a390db
@@ -269,11 +269,14 @@ func Processes(k *kernel.Kernel, out *[]*Process) error {
|
||||
continue
|
||||
}
|
||||
|
||||
ppid := kernel.ThreadID(0)
|
||||
if tg.Leader().Parent() != nil {
|
||||
ppid = ts.Root.IDOfThreadGroup(tg.Leader().Parent().ThreadGroup())
|
||||
}
|
||||
*out = append(*out, &Process{
|
||||
UID: tg.Leader().Credentials().EffectiveKUID,
|
||||
PID: pid,
|
||||
// If Parent is null (i.e. tg is the init process), PPID will be 0.
|
||||
PPID: ts.Root.IDOfTask(tg.Leader().Parent()),
|
||||
UID: tg.Leader().Credentials().EffectiveKUID,
|
||||
PID: pid,
|
||||
PPID: ppid,
|
||||
STime: formatStartTime(now, tg.Leader().StartTime()),
|
||||
C: percentCPU(tg.CPUStats(), tg.Leader().StartTime(), now),
|
||||
Time: tg.CPUStats().SysTime.String(),
|
||||
|
||||
Reference in New Issue
Block a user