1 |
commit: e6be71af3f67ea274db455e9c24d5f84bd372c39 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Sep 27 23:10:40 2015 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 28 16:01:18 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e6be71af |
7 |
|
8 |
AbstractEbuildProcess: remove cgroup with release_agent (bug 561264) |
9 |
|
10 |
Use the cgroup release_agent hook to remove cgroups automatically |
11 |
upon release. |
12 |
|
13 |
X-Gentoo-bug: 561264 |
14 |
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=561264 |
15 |
Acked-by: Alexander Berntsen <bernalex <AT> gentoo.org> |
16 |
|
17 |
bin/cgroup-release-agent | 2 ++ |
18 |
pym/_emerge/AbstractEbuildProcess.py | 14 +++++++------- |
19 |
2 files changed, 9 insertions(+), 7 deletions(-) |
20 |
|
21 |
diff --git a/bin/cgroup-release-agent b/bin/cgroup-release-agent |
22 |
new file mode 100755 |
23 |
index 0000000..7aa6d56 |
24 |
--- /dev/null |
25 |
+++ b/bin/cgroup-release-agent |
26 |
@@ -0,0 +1,2 @@ |
27 |
+#!/bin/bash |
28 |
+exec rmdir "/sys/fs/cgroup/portage/${1}" |
29 |
|
30 |
diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractEbuildProcess.py |
31 |
index 68d96e4..2b5d9c7 100644 |
32 |
--- a/pym/_emerge/AbstractEbuildProcess.py |
33 |
+++ b/pym/_emerge/AbstractEbuildProcess.py |
34 |
@@ -89,6 +89,13 @@ class AbstractEbuildProcess(SpawnProcess): |
35 |
subprocess.check_call(['mount', '-t', 'cgroup', |
36 |
'-o', 'rw,nosuid,nodev,noexec,none,name=portage', |
37 |
'tmpfs', cgroup_portage]) |
38 |
+ with open(os.path.join( |
39 |
+ cgroup_portage, 'release_agent'), 'w') as f: |
40 |
+ f.write(os.path.join(self.settings['PORTAGE_BIN_PATH'], |
41 |
+ 'cgroup-release-agent')) |
42 |
+ with open(os.path.join( |
43 |
+ cgroup_portage, 'notify_on_release'), 'w') as f: |
44 |
+ f.write('1') |
45 |
|
46 |
cgroup_path = tempfile.mkdtemp(dir=cgroup_portage, |
47 |
prefix='%s:%s.' % (self.settings["CATEGORY"], |
48 |
@@ -313,13 +320,6 @@ class AbstractEbuildProcess(SpawnProcess): |
49 |
def _set_returncode(self, wait_retval): |
50 |
SpawnProcess._set_returncode(self, wait_retval) |
51 |
|
52 |
- if self.cgroup is not None: |
53 |
- try: |
54 |
- shutil.rmtree(self.cgroup) |
55 |
- except EnvironmentError as e: |
56 |
- if e.errno != errno.ENOENT: |
57 |
- raise |
58 |
- |
59 |
if self._exit_timeout_id is not None: |
60 |
self.scheduler.source_remove(self._exit_timeout_id) |
61 |
self._exit_timeout_id = None |