Michał Górny avatar Michał Górny committed 511f47f

Restore SIGCHLD handler before attempting to use PM APIs.

In other words, kill the child ASAP and restore the environment
to a sane state. This should fix the issues reported by Zero_Chaos.

Comments (0)

Files changed (1)

smartliverebuild/core.py

 			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
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.