Let's use cgclassify and move all processes where they belong when system boots.
It's very similar to the setup we had before, but we have these improvements:
- all rules are taken into account, user can have different (or no) default
  groups for different controllers
- it's in C, not in ugly shell loop (I have no performance statistics though)
- no 'magic' group is being created automatically by the init script, all
  groups must be in cgconfig.conf

If I am not mistaken, the magic 'ps --no-headers -N --ppid $$ -L o tid' should
print all threads except children of current bash (i.e. everything except ps
itself).

Of course, there is no rule in default cgrules.conf, so it should do nothing
unless the user manually configures something.

Signed-off-by: Jan Safranek <[email protected]>
---

 scripts/init.d/cgconfig.in |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/scripts/init.d/cgconfig.in b/scripts/init.d/cgconfig.in
index 1a13231..445a328 100644
--- a/scripts/init.d/cgconfig.in
+++ b/scripts/init.d/cgconfig.in
@@ -36,6 +36,7 @@ MOUNTS_FILE=/proc/mounts
 PROC_CGROUPS_FILE=/proc/cgroups
 CGROUP_FS=cgroup
 CONFIG_FILE=/etc/cgconfig.conf
+RULES_FILE=/etc/cgrules.conf
 
 # support multiple mount points
 declare -a MOUNTPOINT
@@ -89,6 +90,13 @@ start() {
                 fi
         fi
 
+        # enforce the rules in /etc/cgrules.conf
+        if [ -e $RULES_CONF ]; then
+            # list all processes except the PS itself
+            PROCS=$(ps --no-headers -N --ppid $$ -L o tid)
+            cgclassify $PROCS >/dev/null 2>&1
+        fi
+
         touch /var/lock/subsys/$servicename
         retval=$?
         if [ $retval -ne 0 ]


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Libcg-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to