@@ -366,7 +366,9 @@ type Process struct {
366366 UID auth.KUID `json:"uid"`
367367 PID kernel.ThreadID `json:"pid"`
368368 // Parent PID
369- PPID kernel.ThreadID `json:"ppid"`
369+ PPID kernel.ThreadID `json:"ppid"`
370+ // Process Group ID
371+ PGID kernel.ThreadID `json:"pgid"`
370372 Threads []kernel.ThreadID `json:"threads"`
371373 // Processor utilization
372374 C int32 `json:"c"`
@@ -382,17 +384,18 @@ type Process struct {
382384}
383385
384386// ProcessListToTable prints a table with the following format:
385- // UID PID PPID C TTY STIME TIME CMD
386- // 0 1 0 0 pty/4 14:04 505262ns tail
387+ // UID PID PPID PGID C TTY STIME TIME CMD
388+ // 0 1 0 1 0 pty/4 14:04 505262ns tail
387389func ProcessListToTable (pl []* Process ) string {
388390 var buf bytes.Buffer
389391 tw := tabwriter .NewWriter (& buf , 10 , 1 , 3 , ' ' , 0 )
390- fmt .Fprint (tw , "UID\t PID\t PPID\t C\t TTY\t STIME\t TIME\t CMD" )
392+ fmt .Fprint (tw , "UID\t PID\t PPID\t PGID \ t C\t TTY\t STIME\t TIME\t CMD" )
391393 for _ , d := range pl {
392- fmt .Fprintf (tw , "\n %d\t %d\t %d\t %d\t %s\t %s\t %s\t %s" ,
394+ fmt .Fprintf (tw , "\n %d\t %d\t %d\t %d\t %d \t % s\t %s\t %s\t %s" ,
393395 d .UID ,
394396 d .PID ,
395397 d .PPID ,
398+ d .PGID ,
396399 d .C ,
397400 d .TTY ,
398401 d .STime ,
@@ -447,11 +450,16 @@ func Processes(k *kernel.Kernel, containerID string, out *[]*Process) error {
447450 if p := tg .Leader ().Parent (); p != nil {
448451 ppid = pidns .IDOfThreadGroup (p .ThreadGroup ())
449452 }
453+ pgid := kernel .ThreadID (0 )
454+ if pg := tg .ProcessGroup (); pg != nil {
455+ pgid = kernel .ThreadID (pidns .IDOfProcessGroup (pg ))
456+ }
450457 threads := tg .MemberIDs (pidns )
451458 * out = append (* out , & Process {
452459 UID : tg .Leader ().Credentials ().EffectiveKUID ,
453460 PID : pid ,
454461 PPID : ppid ,
462+ PGID : pgid ,
455463 Threads : threads ,
456464 STime : formatStartTime (now , tg .Leader ().StartTime ()),
457465 C : percentCPU (tg .CPUStats (), tg .Leader ().StartTime (), now ),
0 commit comments