Repository navigation
feat(libkernel_sys): export fork and implement setsid and umask - #3160
Conversation
|
Linux cross-test of 6b7213a merged onto
Two notes:
AI-assisted: yes (Claude Code) |
Dextroid17
left a comment
There was a problem hiding this comment.
The bar is answered before anyone has to ask: XashPS5 (PPSA19111) imports all three, fails to load without them, and the routine that calls them is given by address. Everything after that follows from the fact that this is a system library with no child processes behind it.
fork throwing is the honest choice, and citing execvp in #2827 makes it a decision rather than a gap. setsid failing with EPERM as FreeBSD does for a process group leader — with the note that the guest is already taken to lead its own group, cross-referencing the kill entry — is the detail that stops that one looking arbitrary. And umask keeping the guest's mask, seeded at 022 and masked to 0777 with the previous value returned, is the right half of that call to implement.
The limitation is stated rather than hidden, which is the part worth keeping: files are still created with the host process's mask, and the entry says so. That is the one place a guest could notice — set a restrictive mask, create a file, read its mode back, and the answer comes from the host — so naming it is what makes this landable as a partial implementation rather than a wrong one. If a title ever reaches that check, the entry is where the next person will look first.
Written with AI assistance.
|
@SleglJan thanks for tracing the call sites, my "one routine" was wrong. I pushed a commit that names both functions in the On the test: I left |
Co-Authored-By: Claude <noreply@anthropic.com>
bee0659 to
d4b9808
Compare
|
Checked build and One fix, pushed as a commit on top:
Merging once CI is green. |
What
Three
libkernel_sysexports that XashPS5 (PPSA19111) imports and fails to load without:fork(cjt-4ySmYTs) throwsNotImplemented, since creating a child process is not supported (the same asexecvpin fix(libkernel): export execvp #2827).setsid(edJoqV2FIWs) fails withEPERM, as FreeBSD's does for a process group leader. The guest is already taken to lead its own process group (TechnicalDebt forkill).umask(Rb6ziJKvCCQ) keeps the guest's mask (initially 022, masked to 0777) and returns the previous one. Files are still created with the host process's mask; TechnicalDebt says so.XashPS5's engine (Xash3D FWGS
engine/platform/posix/sys_posix.c, as @SleglJan traced below) calls them from two functions:Posix_Daemonize(fork,setsid,umask), only with-daemonize, andPlatform_ShellExecute(fork, thenexecvp("xdg-open")), which the main menu's Previews button reaches. Neither runs during start-up, but pressing Previews ends in theforkthrow; TechnicalDebt says so.On
mainad33692 (catalog build,eboot.binandsce_module/libc.prxunwrapped as #2605 requires; tracked in #1578), now thatrealpath(#3147) is in:main, Linux:app.elf: symbol lookup error: app.elf: undefined symbol: cjt-4ySmYTsmain, Windows:FAIL: unresolved ELF import cjt-4ySmYTs (fork) from libkernel_sys.prxforkalone:edJoqV2FIWs(setsid); withsetsidtoo:Rb6ziJKvCCQ(umask)main77bd928 (afterctime, feat(libc): implement ctime #3201), Linux:app.elf: symbol lookup error: app.elf: undefined symbol: 5AMS0IntU8I(creat)Tested
Linux (Ubuntu 24.04, GCC 13, Release) on ad33692:
guest_kernel_syspasses 5/5 (--repeat until-fail:5). The new cases check thatsetsidreturns -1 withEPERM, and thatumaskreturns 022 at first, keeps only the permission bits of07777, and returns the previous mask each time. There is no test for theforkexport, since it only throws.check_conventions.pypasses. Windows 11 (MinGW-w64 GCC 15.2 from WinLibs, Release):guest_kernel_sys5/5 with no warnings; with this PR XashPS5 gets pastforkand the Windows loader reportsFAIL: unresolved ELF import 5AMS0IntU8I (creat) from libkernel.prxfirst, which is also missing onmainand is now the Linux stop as well.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)