-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Gavin Halliday <[email protected]>
- Loading branch information
Showing
4 changed files
with
57 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -835,24 +835,28 @@ static const char * queryCGroup() | |
{ | ||
auto processLine = [](size_t len, const char * ln) | ||
{ | ||
//Note ln points at the start of the line, but the line is not null terminated | ||
switch (*ln) | ||
{ | ||
case '0': | ||
if (strncmp(ln, "0::/", 4) == 0) | ||
{ | ||
//Format is 0::/<cgroup>. Note ln points at the start of the line, but the line is not terminated | ||
cgroup.set(ln+4, len-4); | ||
//Format is 0::/<cgroup> | ||
//If not running in a container the "cgroup" may be something like user.slice/user-1000.slice/[email protected]/.... | ||
//If so ignore because it is not a real cgroup | ||
if (!memchr(ln+4, '/', len-4)) | ||
cgroup.set(ln+4, len-4); | ||
} | ||
break; | ||
} | ||
//Some systems with version 1 cgroups have <n>:cpu,cpuacct:/<cgroup> | ||
const char * match = (const char *)jmemmem(len, ln, 14, ":cpu,cpuacct:/"); | ||
if (match) | ||
cgroup.set(match+14, (ln + len) - (match + 14)); | ||
}; | ||
|
||
processLines(contents, processLine); | ||
} | ||
//If not running in a container the "cgroup" may be something like user.slice/user-1000.slice/[email protected]/.... | ||
//If so clear the cached value because it is not a real cgroup | ||
if (cgroup && strchr(cgroup, '/')) | ||
cgroup.clear(); | ||
gatheredGroup = true; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters