public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] AbstractEbuildProcess: remove cgroup with release_agent (bug 561264)
@ 2015-09-27 23:20 Zac Medico
  2015-09-28 13:35 ` Alexander Berntsen
  0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2015-09-27 23:20 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Zac Medico

Use the cgroup release_agent hook to remove cgroups automatically
upon release.

X-Gentoo-bug: 561264
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=561264
---
 bin/cgroup-release-agent             |  2 ++
 pym/_emerge/AbstractEbuildProcess.py | 14 +++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)
 create mode 100755 bin/cgroup-release-agent

diff --git a/bin/cgroup-release-agent b/bin/cgroup-release-agent
new file mode 100755
index 0000000..7aa6d56
--- /dev/null
+++ b/bin/cgroup-release-agent
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec rmdir "/sys/fs/cgroup/portage/${1}"
diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractEbuildProcess.py
index 68d96e4..2b5d9c7 100644
--- a/pym/_emerge/AbstractEbuildProcess.py
+++ b/pym/_emerge/AbstractEbuildProcess.py
@@ -89,6 +89,13 @@ class AbstractEbuildProcess(SpawnProcess):
 					subprocess.check_call(['mount', '-t', 'cgroup',
 						'-o', 'rw,nosuid,nodev,noexec,none,name=portage',
 						'tmpfs', cgroup_portage])
+					with open(os.path.join(
+						cgroup_portage, 'release_agent'), 'w') as f:
+						f.write(os.path.join(self.settings['PORTAGE_BIN_PATH'],
+							'cgroup-release-agent'))
+					with open(os.path.join(
+						cgroup_portage, 'notify_on_release'), 'w') as f:
+						f.write('1')
 
 				cgroup_path = tempfile.mkdtemp(dir=cgroup_portage,
 					prefix='%s:%s.' % (self.settings["CATEGORY"],
@@ -313,13 +320,6 @@ class AbstractEbuildProcess(SpawnProcess):
 	def _set_returncode(self, wait_retval):
 		SpawnProcess._set_returncode(self, wait_retval)
 
-		if self.cgroup is not None:
-			try:
-				shutil.rmtree(self.cgroup)
-			except EnvironmentError as e:
-				if e.errno != errno.ENOENT:
-					raise
-
 		if self._exit_timeout_id is not None:
 			self.scheduler.source_remove(self._exit_timeout_id)
 			self._exit_timeout_id = None
-- 
2.4.6



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gentoo-portage-dev] [PATCH] AbstractEbuildProcess: remove cgroup with release_agent (bug 561264)
  2015-09-27 23:20 [gentoo-portage-dev] [PATCH] AbstractEbuildProcess: remove cgroup with release_agent (bug 561264) Zac Medico
@ 2015-09-28 13:35 ` Alexander Berntsen
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Berntsen @ 2015-09-28 13:35 UTC (permalink / raw
  To: gentoo-portage-dev

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Looks OK.

- -- 
Alexander
bernalex@gentoo.org
https://secure.plaimi.net/~alexander
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCgAGBQJWCUIMAAoJENQqWdRUGk8BFv0QAMG0xJy/tvkHGZL/QweGykIR
5H4VrCZY9i1X/Kvb6orsc/yP8mJYHsbX0ayuy5ihznHsBdPhyr2G6nCtQgqQKozf
3QFIjqLlN6C7dljMr3E41Upw/hkFxT04TWiwtWZvRJeIQ5qh2Mv1sBxjZUMzfG4T
sk+k/FLVWuwrjK5dSQdiKrKPTbA5wMqZ/6DFfN1KTSMyxLp7YCV6ohnloIhQdjgT
TRnmTnszff32yy84p2c13cQc78Ezb8WVtzNgwkYF2C3EZfyW+KV1rPIek29xO8D/
vQzDA3OQF5ls9mv9W19vt2JB0RROWnc/m6nxmQfM2Mok98DRbbKz7RqufNF0ZRc2
BwqLV1YQibk4yb+UAkWsaqsjREmNW/ip8HozBX0RjWuqAnCh8DG3YqLktgGMS4HH
1ngIBOnqpwN1+CCpoEIZl4o5UBOC2+O37STuCDWpCflLmhswz6nP5kNMM/qRAli2
HDeT+MmZTNKpWFWroExuCJQtMHtgz3P5R00yl3r9nELtS5whUqVPLDyp6A4w8KCq
MjmlRRspcl/BY7lO1JUQl0yqI5dDW9gnlwtp9M085GWG/9zxJuuHrrctaiMKtkND
vPAs45Xz3i839W/M+RQI46MD7Jd7f3gQhsgu3t1UezPf2Rj0oraBau0PzsHQ4+l0
06fTvthRavb9a/BpqBv6
=LVfo
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-28 13:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-27 23:20 [gentoo-portage-dev] [PATCH] AbstractEbuildProcess: remove cgroup with release_agent (bug 561264) Zac Medico
2015-09-28 13:35 ` Alexander Berntsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox