From 9fa915eef028c96b8cde3876fb8bb299c03f9a62 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 13 Dec 2011 20:06:10 -0800 Subject: [PATCH] ebuils-ipc.py: _exit in finally block after fork --- bin/ebuild-ipc.py | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) 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')) -- 2.26.2