From: Zac Medico Date: Wed, 14 Dec 2011 04:06:10 +0000 (-0800) Subject: ebuils-ipc.py: _exit in finally block after fork X-Git-Tag: v2.2.0_alpha81~13 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=9fa915eef028c96b8cde3876fb8bb299c03f9a62;p=portage.git ebuils-ipc.py: _exit in finally block after fork --- diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py index 68ad985b6..372585f7b 100755 --- a/bin/ebuild-ipc.py +++ b/bin/ebuild-ipc.py @@ -13,6 +13,7 @@ import select import signal import sys import time +import traceback def debug_signal(signum, frame): import pdb @@ -228,14 +229,22 @@ class EbuildIpc(object): pid = os.fork() if pid == 0: - os.close(pr) - - # File streams are in unbuffered mode since we do atomic - # read and write of whole pickles. - output_file = open(self.ipc_in_fifo, 'wb', 0) - output_file.write(pickle.dumps(args)) - output_file.close() - os._exit(os.EX_OK) + retval = 1 + try: + os.close(pr) + + # File streams are in unbuffered mode since we do atomic + # read and write of whole pickles. + output_file = open(self.ipc_in_fifo, 'wb', 0) + output_file.write(pickle.dumps(args)) + output_file.close() + retval = os.EX_OK + except SystemExit: + raise + except: + traceback.print_exc() + finally: + os._exit(retval) os.close(pw) @@ -258,9 +267,16 @@ class EbuildIpc(object): pid = os.fork() if pid == 0: - os.close(pr) - retval = self._receive_reply(input_fd) - os._exit(retval) + retval = 1 + try: + os.close(pr) + retval = self._receive_reply(input_fd) + except SystemExit: + raise + except: + traceback.print_exc() + finally: + os._exit(retval) os.close(pw) retval = self._wait(pid, pr, portage.localization._('during read'))