From: "William Hubbs" <williamh@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/openrc:master commit in: sh/, etc/
Date: Thu, 17 Nov 2011 22:36:00 +0000 (UTC) [thread overview]
Message-ID: <20df56f0b2a01bd2f8a70b8fb3fbd051c1aab8d8.WilliamH@gentoo> (raw)
commit: 20df56f0b2a01bd2f8a70b8fb3fbd051c1aab8d8
Author: Patrick Lauer <patrick <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 12 21:19:55 2011 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Nov 17 22:22:59 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/openrc.git;a=commit;h=20df56f0
Add CGroup support
X-Gentoo-Bug: 390297
X-Gentoo-Bug: http://bugs.gentoo.org/show_bug.cgi?id=390297
---
etc/rc.conf.Linux | 7 +++++++
sh/runscript.sh.in | 22 ++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/etc/rc.conf.Linux b/etc/rc.conf.Linux
index 9b5859a..585da3c 100644
--- a/etc/rc.conf.Linux
+++ b/etc/rc.conf.Linux
@@ -1,3 +1,10 @@
+# Set the control group for this service.
+# If you do not set this, the default setting is the value of
+# RC_SVCNAME.
+# This setting is ignored if you do not have CONFIG_CGROUPS active in
+# your kernel.
+# RC_CGROUP="foo"
+
##############################################################################
# LINUX SPECIFIC OPTIONS
diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in
index f86a510..73b4a59 100644
--- a/sh/runscript.sh.in
+++ b/sh/runscript.sh.in
@@ -189,6 +189,16 @@ fi
# Load any system overrides
sourcex -e "@SYSCONFDIR@/rc.conf"
+# Attach to CGroup - dir existing is enough for us
+if [ -d /sys/fs/cgroup/ ]; then
+ # use RC_SVCNAME unless overridden in conf.d
+ SVC_CGROUP=${RC_CGROUP:-$RC_SVCNAME}
+ mkdir -p /sys/fs/cgroup/${SVC_CGROUP}
+ # now attach self to cgroup - any children of this process will inherit this
+ echo $$ > /sys/fs/cgroup/${SVC_CGROUP}/tasks
+ # TODO: set res limits from conf.d
+fi
+
# Apply any ulimit defined
[ -n "${rc_ulimit:-$RC_ULIMIT}" ] && ulimit ${rc_ulimit:-$RC_ULIMIT}
@@ -291,3 +301,15 @@ while [ -n "$1" ]; do
eerror "$RC_SVCNAME: unknown function \`$1'"
exit 1
done
+
+# CGroup cleanup
+if [ -d /sys/fs/cgroup/ ]; then
+ # use RC_SVCNAME unless overridden in conf.d
+ SVC_CGROUP=${RC_CGROUP:-$RC_SVCNAME}
+ # reattach to root cgroup
+ echo $$ > /sys/fs/cgroup/tasks
+ # remove cgroup if empty, will fail if any task attached
+ rmdir /sys/fs/cgroup/${SVC_CGROUP} 2>/dev/null
+fi
+
+exit 0
next reply other threads:[~2011-11-17 22:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-17 22:36 William Hubbs [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-11-17 22:46 [gentoo-commits] proj/openrc:master commit in: sh/, etc/ William Hubbs
2012-11-12 17:00 William Hubbs
2013-02-19 23:11 William Hubbs
2013-03-12 18:10 William Hubbs
2013-04-25 22:02 William Hubbs
2015-05-08 17:11 William Hubbs
2015-10-06 21:34 William Hubbs
2016-12-17 22:57 William Hubbs
2017-09-15 18:31 William Hubbs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20df56f0b2a01bd2f8a70b8fb3fbd051c1aab8d8.WilliamH@gentoo \
--to=williamh@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox