diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2015-03-16 03:22:33 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-03-16 03:22:33 -0300 |
commit | 5c8b83405b5e9234ac1d820162e3c66c0e9df648 (patch) | |
tree | a1d1492c3f949c29b94e7150fd1e4378994a9505 /linux | |
parent | ddbb71d1c8c78183fa92a981fef9856afff67bce (diff) | |
parent | a4b03e8875bcbcacefd506f72e14b781e8010b74 (diff) |
Merge branch 'master' into wip
Conflicts:
Process.c
Process.h
linux/LinuxProcess.c
linux/LinuxProcess.h
linux/LinuxProcessList.c
unsupported/Platform.c
unsupported/Platform.h
Diffstat (limited to 'linux')
-rw-r--r-- | linux/LinuxProcessList.c | 31 | ||||
-rw-r--r-- | linux/Platform.c | 1 | ||||
-rw-r--r-- | linux/Platform.h | 1 |
3 files changed, 20 insertions, 13 deletions
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c index 9d01ce60..9770ab09 100644 --- a/linux/LinuxProcessList.c +++ b/linux/LinuxProcessList.c @@ -361,22 +361,27 @@ static void LinuxProcessList_readCGroupFile(LinuxProcess* process, const char* d process->cgroup = strdup(""); return; } - char buffer[256]; - char *ok = fgets(buffer, 255, file); - if (ok) { - char* trimmed = String_trim(buffer); - int nFields; - char** fields = String_split(trimmed, ':', &nFields); - free(trimmed); - free(process->cgroup); - if (nFields >= 3) { - process->cgroup = strndup(fields[2] + 1, 10); - } else { - process->cgroup = strdup(""); + char output[256]; + output[0] = '\0'; + char* at = output; + int left = 255; + while (!feof(file) && left > 0) { + char buffer[256]; + char *ok = fgets(buffer, 255, file); + if (!ok) break; + char* group = strchr(buffer, ':'); + if (!group) break; + if (at != output) { + *at = ';'; + at++; + left--; } - String_freeArray(fields); + int wrote = snprintf(at, left, "%s", group); + left -= wrote; } fclose(file); + free(process->cgroup); + process->cgroup = strdup(output); } #endif diff --git a/linux/Platform.c b/linux/Platform.c index d89b4820..5ade6e9d 100644 --- a/linux/Platform.c +++ b/linux/Platform.c @@ -30,6 +30,7 @@ in the source distribution for its full text. #include "Action.h" #include "MainPanel.h" #include "BatteryMeter.h" +#include "LinuxProcess.h" }*/ ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; diff --git a/linux/Platform.h b/linux/Platform.h index a00208ef..3757855d 100644 --- a/linux/Platform.h +++ b/linux/Platform.h @@ -12,6 +12,7 @@ in the source distribution for its full text. #include "Action.h" #include "MainPanel.h" #include "BatteryMeter.h" +#include "LinuxProcess.h" extern ProcessField Platform_defaultFields[]; |