MergeProcess: suppress finally blocks after fork
authorZac Medico <zmedico@gentoo.org>
Sat, 13 Nov 2010 17:16:08 +0000 (09:16 -0800)
committerZac Medico <zmedico@gentoo.org>
Sat, 13 Nov 2010 17:16:08 +0000 (09:16 -0800)
This case is like bug #345289.

pym/portage/dbapi/_MergeProcess.py

index b5af7142c35bc1f131dc38d591958e8fd6699962..3cf50d22bd7db7978044af0ac04f261f106fa861 100644 (file)
@@ -1,6 +1,8 @@
 # Copyright 2010 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
+import traceback
+
 import portage
 from portage import os
 from _emerge.SpawnProcess import SpawnProcess
@@ -35,7 +37,15 @@ class MergeProcess(SpawnProcess):
                # is triggered when dblink._scheduler is None.
                self.dblink._scheduler = None
 
-               rval = self.dblink._merge_process(self.srcroot, self.destroot,
-                       self.cfgfiledict, self.conf_mem_file)
-
-               os._exit(rval)
+               rval = 1
+               try:
+                       rval = self.dblink._merge_process(self.srcroot, self.destroot,
+                               self.cfgfiledict, self.conf_mem_file)
+               except SystemExit:
+                       raise
+               except:
+                       traceback.print_exc()
+               finally:
+                       # Call os._exit() from finally block, in order to suppress any
+                       # finally blocks from earlier in the call stack. See bug #345289.
+                       os._exit(rval)