s-l-r: actually include the new patch

This commit is contained in:
Zero_Chaos 2012-10-31 17:19:54 +00:00
parent 36fd21af13
commit 6443e4a0af

View file

@ -0,0 +1,42 @@
diff --git a/smartliverebuild/core.py b/smartliverebuild/core.py
index e367111..f213c66 100644
--- a/smartliverebuild/core.py
+++ b/smartliverebuild/core.py
@@ -22,6 +22,7 @@ def SmartLiveRebuild(opts, pm, cliargs = None):
out.err('The argument to --jobs option must be a positive integer.')
raise SLRFailure('')
+ global childpid
childpid = None
commpipe = None
superuser = (os.geteuid() == 0)
@@ -31,9 +32,18 @@ def SmartLiveRebuild(opts, pm, cliargs = None):
portage_gid = pm_conf.userpriv_gid
if portage_uid and portage_gid:
if superuser:
+ def chld_handler(sig, frame):
+ global childpid
+ if os.wait()[0] == childpid:
+ childpid = None
+
out.s1('Forking to drop superuser privileges ...')
+ old_chld = signal.signal(signal.SIGCHLD, chld_handler)
commpipe = os.pipe()
childpid = os.fork()
+
+ if childpid == 0:
+ signal.signal(signal.SIGCHLD, old_chld)
else:
out.err("setuid requested but there's no 'portage' user in the system")
return 1
@@ -180,9 +190,6 @@ option.
out.result('Found %s%d%s packages to rebuild.' % (out.white, len(packages), out.s1reset))
finally:
if childpid: # make sure that we leave no orphans
- try:
- os.kill(childpid, signal.SIGTERM)
- except OSError:
- pass
+ os.kill(childpid, signal.SIGTERM)
return packages