Add very basic Linux control groups support #215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Control groups (cgroups) are a Linux kernel feature that can be used for
resource management and isolation between processes. In my case, I have an
out-of-band application that manages the cgroups themselves, but as I use
supervisor to manage process lifecycle, it's well positioned to attach
processes to cgroups, and to reattach them if they're autorestarted.
Here we do that, with two main changes:
cgroup by writing its pid to each 'tasks' pseudofile. Note that cgroup
membership is per-thread (not per-process), but at this stage in the
process' life, it should be single threaded.
if the process has cgroups or not. Ideally we'd take into account whether
attaching actually succeeded, but effecting that change in the parent is
tough from the forked child.