mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-18 23:07:07 -05:00
sceSystemServiceLoadExec found its own executable through /proc/self/exe and replaced the process with fexecve after close_range, none of which macOS has, so on macOS every call except "exit" threw. On macOS: - the running executable's path comes from _NSGetExecutablePath, resolved with std::filesystem::canonical, as libSceNpEntitlementAccess and libSceFont already do; - the target must be an x86-64 Mach-O executable (MH_MAGIC_64, CPU_TYPE_X86_64, MH_EXECUTE) that the user may run; - macOS has no fexecve, so the process is replaced by path with posix_spawn and POSIX_SPAWN_SETEXEC; POSIX_SPAWN_CLOEXEC_DEFAULT closes every descriptor but the standard streams, as close_range does on Linux; - before the replacement the exit starts and the shutdown callbacks run (LibcStartExit, then LibcRunShutdown), as on Linux, so guest threads that call a stopped library wait instead of unwinding; - descriptor 2 gets the host standard error back before the replacement, as on Linux, and guest_system_load_exec_standard_error runs on macOS. A launch without arguments keeps the Linux execv path, which macOS has. guest_system_exit finds its own executable the same way on macOS.