AnyPS5/docs/dev
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
..
debt feat(libkernel): implement pthread_atfork 2026-10-13 07:38:13 +00:00
ARCHITECTURE.md feat(agc): depth planes sampled as 2D arrays, cubes and integer views 2026-10-13 12:11:02 +13:00
BUILD.md Merge pull request #4607 from yunusshaikh7/feat/tracy-profiler 2026-10-12 23:09:21 +02:00
CONVENTIONS.md refactor(docs): separated user and dev in docs + compatibility file 2026-09-28 22:58:17 +03:00
HW_ORACLE.md feat(shader): follow FP16_OVFL in every f16 result 2026-10-10 04:32:38 -03:00
PROGRESS.md feat(progress): publish a progress history chart 2026-10-12 21:31:09 +02:00
TechnicalDebt.md Merge pull request #4682 from bubblegg/feat/netctl-get-if-stat 2026-10-13 09:26:47 +02:00