In portage.process.spawn it calls portage._ForkWatcher.hook(portage._ForkWatcher) after os.fork() in order to ensure that any portage.getpid() calls will work correctly (a pre_exec function could conceivably call portage.getpid()). The hook call introduces an unnecessary os.getpid() call in cases here portage.getpid() will not be called after fork. The unnecessary os.getpid() call can by avoided if we make portage.getpid() call os.getpid() lazily.
Patch: https://archives.gentoo.org/gentoo-portage-dev/message/78bfc400ada17f1343fcab2c92d5757c https://github.com/gentoo/portage/pull/667
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/proj/portage.git/commit/?id=ef43dd8ef64ded5f0627b7b8e84ef21262012902 commit ef43dd8ef64ded5f0627b7b8e84ef21262012902 Author: Zac Medico <zmedico@gentoo.org> AuthorDate: 2021-01-30 12:44:19 +0000 Commit: Zac Medico <zmedico@gentoo.org> CommitDate: 2021-02-08 04:47:20 +0000 portage.getpid: call os.getpid() lazily Call os.getpid() lazily, which eliminates getpid calls when possible after os.fork() in the portage.process module. Bug: https://bugs.gentoo.org/767913 Reviewed-by: Brian Dolbec <dolsen@gentoo.org> Signed-off-by: Zac Medico <zmedico@gentoo.org> lib/portage/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6b98e103aa15da331d647a8f65a45bb3bb4e3197 commit 6b98e103aa15da331d647a8f65a45bb3bb4e3197 Author: Zac Medico <zmedico@gentoo.org> AuthorDate: 2021-02-22 13:46:04 +0000 Commit: Zac Medico <zmedico@gentoo.org> CommitDate: 2021-02-22 13:54:29 +0000 sys-apps/portage: Bump to version 3.0.15 #715112 default enable FEATURES=binpkg-multi-instance #756778 content-hash distfiles layout #766459 emirrordist: prevent distfiles_db _pkg_str pickle problems #766767 emaint --fix merges: add -y, --yes option #766773 emerge: disable --autounmask-license by default #767913 portage.getpid: call os.getpid() lazily #770712 PopenProcess: use call_soon for _async_waipid in _start #771549 prevent USE="${USE} ..." misbehavior Bug: https://bugs.gentoo.org/766117 Bug: https://bugs.gentoo.org/715112 Bug: https://bugs.gentoo.org/756778 Bug: https://bugs.gentoo.org/766459 Bug: https://bugs.gentoo.org/766767 Bug: https://bugs.gentoo.org/766773 Bug: https://bugs.gentoo.org/767913 Bug: https://bugs.gentoo.org/770712 Bug: https://bugs.gentoo.org/771549 Package-Manager: Portage-3.0.15, Repoman-3.0.2 Signed-off-by: Zac Medico <zmedico@gentoo.org> sys-apps/portage/Manifest | 1 + sys-apps/portage/portage-3.0.15.ebuild | 268 +++++++++++++++++++++++++++++++++ 2 files changed, 269 insertions(+)