summaryrefslogtreecommitdiffhomepage
path: root/pkg
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-09-26 21:58:54 -0700
committerShentubot <shentubot@google.com>2018-09-26 22:00:04 -0700
commitfca9a390db4c965b4606dd85838460841bd4ab14 (patch)
tree3f6105d71064ec1e091f39afdb06d28deadff792 /pkg
parenta003e041c86198122af7e37cc171517f977dde6a (diff)
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
Diffstat (limited to 'pkg')
-rw-r--r--pkg/sentry/control/proc.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/pkg/sentry/control/proc.go b/pkg/sentry/control/proc.go
index 68d3b179b..b120471cb 100644
--- a/pkg/sentry/control/proc.go
+++ b/pkg/sentry/control/proc.go
@@ -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(),