AnyPS5/core/libs/prx/libkernel
David e8fd542f03 feat(libkernel): implement pthread_atfork
pthread_atfork (U9t5kJAWPnA, aerolib) appends the prepare, parent and
child handlers to a process-wide list under a lock and returns 0, or
ENOMEM when the entry cannot be allocated, as FreeBSD 11.4's
_pthread_atfork does (lib/libthr/thread/thr_fork.c:78-100, freebsd-src
8c639945a44588f6cfdddfb057bb5aad88735da0). Null handlers are accepted;
FreeBSD's fork skips them. The handlers never run: fork
(libkernel_sys) throws and vfork is absent, so no child process is
created. The list is kept, in registration order, for a later fork
(PthreadAtforkHandlers_nid_no_patch); recorded in TechnicalDebt.

XPSemu (PPSA97358) calls it from a constructor, before main
(ZiZc3/XPSemu 8eec07b4, util/rcu.c:488-495):

    static void __attribute__((__constructor__)) rcu_init(void)
    {
        smp_mb_global_init();
    #ifdef CONFIG_POSIX
        pthread_atfork(rcu_init_lock, rcu_init_unlock, rcu_init_child);
    #endif
        rcu_init_complete();
    }

so a throwing export would stop the title before main. Predicted stop
removed (registry index 255, not run):
FAIL: unresolved ELF import U9t5kJAWPnA from libkernel.prx

guest_pthread_atfork checks registration order, null handlers,
concurrent registration from four threads and that no handler runs.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
(cherry picked from commit f37bccf6efd76edcde5d582800c89b83fdd30472)
2026-10-13 07:38:13 +00:00
..
Aio/src fix(aio): use precise polling sleep 2026-10-11 18:48:18 -04:00
AppMetadata Merge pull request #4558 from MiniRML/fix/kernel-json-number-locale 2026-10-13 15:37:49 +13:00
Apr fix(libkernel): report the target size of symbolic links on Windows 2026-10-12 13:48:56 +05:30
DirectMemory fix(libkernel): accept flag 0x8000 in sceKernelMapFlexibleMemory 2026-10-12 15:38:48 -07:00
Equeue fix(libkernel): route equeue socket checks by membership 2026-10-13 03:28:27 +00:00
EventFlag/src feat(runtime): timed waits, sync primitive fixes, heap and RTC fixes, unattended-run switches 2026-09-26 19:00:39 -07:00
File Merge pull request #4391 from MarcZX100/codex/socket-descriptors-4366 2026-10-13 19:52:08 +13:00
Module Merge pull request #4688 from eliyarson/fix/kernel-stat-relinked-prx 2026-10-13 17:48:42 +13:00
Pthread feat(libkernel): implement pthread_atfork 2026-10-13 07:38:13 +00:00
Semaphore fix(libkernel): report the remaining time from sceKernelWaitSema 2026-10-11 20:09:33 +00:00
Socket Merge pull request #4391 from MarcZX100/codex/socket-descriptors-4366 2026-10-13 19:52:08 +13:00
SyncOnAddress/src feat(libkernel): wake each listed address in _umtx_op UMTX_OP_NWAKE_PRIVATE 2026-10-11 17:48:06 +00:00
System Merge pull request #4197 from MarcZX100/codex/audit-coredump-userdata 2026-10-13 18:24:28 +13:00
Time Merge pull request #4466 from babyhuey/feat/libkernel-socid-cpumode 2026-10-13 07:27:28 +13:00
CMakeLists.txt feat(libkernel): implement pthread_atfork 2026-10-13 07:38:13 +00:00
KernelErrors.hpp refactor(kernel): share SCE kernel error codes through KernelErrors.hpp 2026-09-27 13:32:28 +07:00
Unimplemented.cpp feat(libkernel): implement the coredump user-data calls 2026-10-13 04:43:50 +00:00