Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH] atexit does not work with os.execv
Date: Mon, 06 Feb 2006 07:05:55
Message-Id: 43E6F686.1040709@gentoo.org
1 -----BEGIN PGP SIGNED MESSAGE-----
2 Hash: SHA1
3
4 Hi everyone,
5
6 While auditing the code related to bug 117988, I've noticed that it calls portageexit() directly because the normal atexit hooks do not work with the os.execv call when portage restarts itself. Currently, several other atexit hooks exist but never get called when portage restarts itself.
7
8 Unfortunately, python's atexit module does not have a public interface for anything but the register() function (_exithandlers and _run_exitfuncs are accessible but undocumented). In the attached patch, I've copied the private code (GPL compatible) directly from /usr/lib/python2.4/atexit.py so that the functionality is duplicated in our portage_exec module. Then I've wrapped all relevant access to the atexit module in calls to the new portage_exec.atexit_register() function. The last hunk uses the new function portage_exec.run_exitfuncs() to manually call the registered functions prior to the os.execv call. Feedback would be appreciated.
9
10 Zac
11 -----BEGIN PGP SIGNATURE-----
12 Version: GnuPG v1.4.2 (GNU/Linux)
13
14 iD8DBQFD5vaC/ejvha5XGaMRAmvFAJ90D3b5N6t8YiVjy4Qp0woo/tFm9wCeNwYH
15 QDCajTK1JPea2fg+AT7WDEs=
16 =8DuV
17 -----END PGP SIGNATURE-----

Attachments

File name MIME type
atexit_register.patch text/x-patch