Skip to content

Commit

Permalink
Restore SIGCHLD handler before attempting to use PM APIs.
Browse files Browse the repository at this point in the history
In other words, kill the child ASAP and restore the environment
to a sane state. This should fix the issues reported by Zero_Chaos.
  • Loading branch information
mgorny committed Nov 15, 2012
1 parent aed250a commit 511f47f
Showing 1 changed file with 27 additions and 26 deletions.
53 changes: 27 additions & 26 deletions smartliverebuild/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,36 +162,37 @@ def loop_iter(blocking = False):
packages = pdata['packages']
erraneous = pdata['erraneous']

if opts.erraneous_merge and len(erraneous) > 0:
packages.extend(erraneous)

# Check portdb for matches. Drop unmatched packages.
for p in list(packages):
if pm.Atom(p) not in pm.stack:
out.err('No packages matching %s in portdb, skipping.' % p)
packages.remove(p)

if not opts.pretend and opts.quickpkg and len(packages) >= 1:
out.s1('Calling quickpkg to create %s%d%s binary packages ...' % (out.white, len(packages), out.s1reset))

# backwards compat, nowadays quickpkg is in ${PATH}
if os.path.exists('/usr/sbin/quickpkg'):
cmd = ['/usr/sbin/quickpkg']
else:
cmd = ['quickpkg']
cmd.append('--include-config=y')
cmd.extend(packages)
out.s2(' '.join(cmd))
subprocess.Popen(cmd, stdout=sys.stderr).wait()

if len(packages) < 1:
out.result('No updates found')
else:
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
if childpid not in dead_children:
os.kill(childpid, signal.SIGTERM)
signal.signal(signal.SIGCHLD, old_chld)

if opts.erraneous_merge and len(erraneous) > 0:
packages.extend(erraneous)

# Check portdb for matches. Drop unmatched packages.
for p in list(packages):
if pm.Atom(p) not in pm.stack:
out.err('No packages matching %s in portdb, skipping.' % p)
packages.remove(p)

if not opts.pretend and opts.quickpkg and len(packages) >= 1:
out.s1('Calling quickpkg to create %s%d%s binary packages ...' % (out.white, len(packages), out.s1reset))

# backwards compat, nowadays quickpkg is in ${PATH}
if os.path.exists('/usr/sbin/quickpkg'):
cmd = ['/usr/sbin/quickpkg']
else:
cmd = ['quickpkg']
cmd.append('--include-config=y')
cmd.extend(packages)
out.s2(' '.join(cmd))
subprocess.Popen(cmd, stdout=sys.stderr).wait()

if len(packages) < 1:
out.result('No updates found')
else:
out.result('Found %s%d%s packages to rebuild.' % (out.white, len(packages), out.s1reset))

return packages

0 comments on commit 511f47f

Please sign in to comment.