ProcessList: add support for cgroups
ClosedPublic

Authored by topimiettinen on Apr 24 2019, 12:57 PM.

Details

Summary

Signed-off-by: Topi Miettinen <toiwoton@gmail.com>

Diff Detail

Repository
R106 KSysguard
Branch
processlist-add-cgroup
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 11273
Build 11291: arc lint + arc unit
topimiettinen created this revision.Apr 24 2019, 12:57 PM
Restricted Application added a project: Plasma. · View Herald TranscriptApr 24 2019, 12:57 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
topimiettinen requested review of this revision.Apr 24 2019, 12:57 PM

Sample output:

ksysguardd> ps?
Name    PID     PPID    UID     GID     Status  User Time       System Time     Nice    VmSize  VmRss   VmURss  Login   TracerPID       TTY     Command IO Priority Class       IO Priority     NNP     CGroup
s       d       d       d       d       S       d       d       d       D       D       D       s       d       s       s       d       d       d       s
ksysguardd> ps
init    1       -1      0       0       sleeping        127     308     0       172216  12060   3176    root    -1              /sbin/init      0       0       0       /init.scope
systemd-udevd   476     1       0       0       sleeping        15      18      0       22900   5616    1520    root    -1              /lib/systemd/systemd-udevd      0       0       1       /system.slice/systemd-udevd.service
kwin_x11        958     950     1000    1000    sleeping        13918   19025   0       2638008 75776   15984   topi    -1              /usr/bin/kwin_x11 -session 10cd6f6f72000148377699300000009690022_1544638428_145716      0       0       0       /user.slice/user-1000.slice/session-1.scope

trim trailing newlines

anthonyfieroni added inline comments.
ksysguardd/Linux/ProcessList.c
420–421
for (int i = strlen(buf) - 1; buf[i] == '\n'; i++)
    buf[i] = '\0';
422

strdup allocates memory i don't see where you free it.

free strdup'ed string

improve trimming, thanks to @anthonyfieroni

topimiettinen marked 2 inline comments as done.Apr 27 2019, 8:34 AM
anthonyfieroni added inline comments.Apr 27 2019, 9:51 AM
ksysguardd/Linux/ProcessList.c
420–421

I made mistake i mean i-- we start from last.

more trimming logic fixes

topimiettinen marked an inline comment as done.Apr 27 2019, 10:04 AM
topimiettinen added inline comments.
ksysguardd/Linux/ProcessList.c
420–421

I also added a check for i not being negative.

topimiettinen marked an inline comment as done.Apr 27 2019, 10:06 AM

avoid memory allocations and reuse existing validation function

davidedmundson accepted this revision.May 16 2019, 11:31 PM
This revision is now accepted and ready to land.May 16 2019, 11:31 PM
This revision was automatically updated to reflect the committed changes.