diff --git a/sh/runscript.sh.in b/sh/runscript.sh.in index 859cfa8..d1f5e95 100644 --- a/sh/runscript.sh.in +++ b/sh/runscript.sh.in @@ -280,3 +280,15 @@ while [ -n "$1" ]; do eerror "$RC_SVCNAME: unknown function \`$1'" exit 1 done + +# CGroup cleanup +if [ -d /sys/fs/cgroup/ ]; then + # use the svcname unless overriden in conf.d + SVC_CGROUP=${CGROUP:-$RC_SVCNAME} + # reattach ourself 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 +# need to exit cleanly +exit 0