aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2024-08-13 22:30:42 -0700
committerZac Medico <zmedico@gentoo.org>2024-08-14 08:22:05 -0700
commitcfd767cd35f5affd3b61b665b0f8814fe2de24c4 (patch)
treef01e4a50796d05b49e8165816c503276efd10f3a /lib
parent_EbuildFetcherProcess: Suppress CancelledError (diff)
downloadportage-cfd767cd35f5affd3b61b665b0f8814fe2de24c4.tar.gz
portage-cfd767cd35f5affd3b61b665b0f8814fe2de24c4.tar.bz2
portage-cfd767cd35f5affd3b61b665b0f8814fe2de24c4.zip
run_exitfuncs: Drop hooks inherited via fork
Drop hooks inherited via fork because they can trigger redundant actions as shown in bug 937891. Note that atexit hooks only work after fork since issue 83856 was fixed in Python 3.13. Bug: https://bugs.gentoo.org/937891 Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/portage/process.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/portage/process.py b/lib/portage/process.py
index 38adebda6..e6f6feb35 100644
--- a/lib/portage/process.py
+++ b/lib/portage/process.py
@@ -208,7 +208,7 @@ def atexit_register(func, *args, **kargs):
# which is associated with the current thread.
global_event_loop()._coroutine_exithandlers.append((func, args, kargs))
else:
- _exithandlers.append((func, args, kargs))
+ _exithandlers.append((func, args, kargs, portage.getpid()))
def run_exitfuncs():
@@ -222,7 +222,12 @@ def run_exitfuncs():
# original function is in the output to stderr.
exc_info = None
while _exithandlers:
- func, targs, kargs = _exithandlers.pop()
+ func, targs, kargs, pid = _exithandlers.pop()
+ if pid != portage.getpid():
+ # Drop hooks inherited via fork because they can trigger redundant
+ # actions as shown in bug 937891. Note that atexit hooks only work
+ # after fork since issue 83856 was fixed in Python 3.13.
+ continue
try:
func(*targs, **kargs)
except SystemExit: