Support for cgroups (thanks to Guillaume Zitta and Daniel Lezcano)

This commit is contained in:
Hisham Muhammad
2010-10-30 19:24:07 +00:00
parent b2fee47a14
commit 84ed4c01f6
5 changed files with 54 additions and 1 deletions

View File

@ -642,6 +642,26 @@ static bool ProcessList_processEntries(ProcessList* this, const char* dirname, P
}
#endif
#ifdef HAVE_CGROUP
snprintf(statusfilename, MAX_NAME, "%s/%s/cgroup", dirname, name);
status = ProcessList_fopen(this, statusfilename, "r");
if (status) {
char buffer[256];
char *ok = fgets(buffer, 255, status);
if (ok) {
char* trimmed = String_trim(buffer);
char** fields = String_split(trimmed, ':');
free(trimmed);
char* value = String_cat(fields[2], " ");
String_freeArray(fields);
process->cgroup = strndup(value + 1, 10);
free(value);
}
fclose(status);
}
#endif
#ifdef HAVE_VSERVER
snprintf(statusfilename, MAX_NAME, "%s/%s/status", dirname, name);
status = ProcessList_fopen(this, statusfilename, "r");