5 Commits
Author SHA1 Message Date
mugurc f347461351 feat(libSceSystemService): LoadExec on macOS hosts
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.
2026-10-18 16:05:07 +03:00
milescovielloandClaude Opus 5.5 e71ade0ac3 fix(libSceSystemService): run the shutdown callbacks after LoadExec starts the exit
Since #5978, StartExit only parks the other guest threads and exit runs
LibcRunShutdown itself, so LoadExec's three exits (the converted
executable on Windows and Linux, and the host executable) now call
LibcStartExit and then LibcRunShutdown, as exit does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 10:50:52 +00:00
milescovielloandClaude Opus 5.5 5b072bc2c4 fix(libSceSystemService): park guest threads during LoadExec's shutdown as exit does
Metal Gear Solid 4 (PPSA18194) aborts on main when its launcher starts
the game: sceSystemServiceLoadExec runs the guest shutdown, a render
thread that then calls into the stopped AGC driver gets ProcessShutdown
back from LibcAwaitExit, and the exception unwinds into title code,
which terminates the process before the new executable starts.

LibcAwaitExit parks a thread only once an exit has been requested, and
LoadExec ran the shutdown without requesting one. It now starts the
shutdown the way exit does, so such threads wait until the process is
replaced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-17 10:50:36 +00:00
Yossi Yadgar 45cb1f91a0 fix(libSceSystemService): give the host standard error back before LoadExec's fexecve
A LoadExec with an argument list replaces the process through Replace (fexecve), which runs before StartHostExecutable, so the next image still wrote to the title's redirect. Descriptor 2 now gets the kept host descriptor there too, after the shutdown and the flush and before close_range closes it.
2026-10-15 18:17:21 +03:00
Evgeniy KazarinandClaude Opus 5.5 a1b80121c1 fix(libSceSystemService): pass LoadExec arguments as the whole guest argv
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-14 18:41:25 +03:00