Fix possible panic in control.Processes.
There was a race where we checked task.Parent() != nil, and then later called task.Parent() again, assuming that it is not nil. If the task is exiting, the parent may have been set to nil in between the two calls, causing a panic. This CL changes the code to only call task.Parent() once. PiperOrigin-RevId: 215274456 Change-Id: Ib5a537312c917773265ec72016014f7bc59a5f59
This commit is contained in:
parent
a2ad8fef13
commit
07aa040842
|
@ -278,8 +278,8 @@ func Processes(k *kernel.Kernel, containerID string, out *[]*Process) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
ppid := kernel.ThreadID(0)
|
ppid := kernel.ThreadID(0)
|
||||||
if tg.Leader().Parent() != nil {
|
if p := tg.Leader().Parent(); p != nil {
|
||||||
ppid = ts.Root.IDOfThreadGroup(tg.Leader().Parent().ThreadGroup())
|
ppid = ts.Root.IDOfThreadGroup(p.ThreadGroup())
|
||||||
}
|
}
|
||||||
*out = append(*out, &Process{
|
*out = append(*out, &Process{
|
||||||
UID: tg.Leader().Credentials().EffectiveKUID,
|
UID: tg.Leader().Credentials().EffectiveKUID,
|
||||||
|
|
Loading…
Reference in New Issue