aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2015-04-13 11:15:58 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2015-04-21 11:30:24 -0500
commit15ab3f39c69ff8d69fd08a9cde7495a04b4dec9e (patch)
treeb8cbff4dd7e807be2ea74ef5105d80b13a596160
parentee1768a419122d288256cce1723d4997bd965eab (diff)
cgroups: use printf to write to cgroup files
This fixes #33.
-rw-r--r--sh/rc-cgroup.sh.in11
1 files changed, 6 insertions, 5 deletions
diff --git a/sh/rc-cgroup.sh.in b/sh/rc-cgroup.sh.in
index 04260265..c7cac2a9 100644
--- a/sh/rc-cgroup.sh.in
+++ b/sh/rc-cgroup.sh.in
@@ -1,6 +1,7 @@
#!@SHELL@
# Copyright (c) 2012 Alexander Vershilov <qnikst@gentoo.org>
# Released under the 2-clause BSD license.
+
extra_stopped_commands="${extra_stopped_commands} cgroup_cleanup"
description_cgroup_cleanup="Kill all processes in the cgroup"
@@ -47,7 +48,7 @@ cgroup_set_values()
$controller.*)
if [ -n "$name" -a -f "$cgroup/$name" -a -n "$val" ]; then
veinfo "$RC_SVCNAME: Setting $cgroup/$name to $val"
- echo $val > "$cgroup/$name"
+ printf "%s" "$val" > "$cgroup/$name"
fi
name=$1
val=
@@ -60,12 +61,12 @@ cgroup_set_values()
done
if [ -n "$name" -a -f "$cgroup/$name" -a -n "$val" ]; then
veinfo "$RC_SVCNAME: Setting $cgroup/$name to $val"
- echo $val > "$cgroup/$name"
+ printf "%s" "$val" > "$cgroup/$name"
fi
if [ -f "$cgroup/tasks" ]; then
veinfo "$RC_SVCNAME: adding to $cgroup/tasks"
- echo 0 > "$cgroup/tasks"
+ printf "%d" 0 > "$cgroup/tasks"
fi
return 0
@@ -78,14 +79,14 @@ cgroup_add_service()
# cgroups. But may lead to a problems where that inheriting
# is needed.
for d in /sys/fs/cgroup/* ; do
- [ -f "${d}"/tasks ] && echo 0 > "${d}"/tasks
+ [ -f "${d}"/tasks ] && printf "%d" 0 > "${d}"/tasks
done
openrc_cgroup=/sys/fs/cgroup/openrc
if [ -d "$openrc_cgroup" ]; then
cgroup="$openrc_cgroup/$RC_SVCNAME"
mkdir -p "$cgroup"
- [ -f "$cgroup/tasks" ] && echo 0 > "$cgroup/tasks"
+ [ -f "$cgroup/tasks" ] && printf "%d" 0 > "$cgroup/tasks"
fi
}