Supervisor/supervisor — pull request #215 by adembo (2013-02-08 08:40:14+00:00)
Title: Add very basic Linux control groups support

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:
1. After forking a process, supervisor will attach it to every desired
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.
2. When queried for process information, supervisor will also mention
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.