feat(libkernel): report no child processes from waitpid #2123
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2123"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by LuisBiceps on 2026-10-09T09:28:41Z.
What
Exports
waitpid(NIDdTnYqqLIQ6c) from libkernel. AnyPS5 runs the title as one host process and exports nothing that creates a child (fork,vfork,rfork,posix_spawn), sowaitpidanswers the way FreeBSD 11's kernel does for a process without children:WNOHANG,WUNTRACED,WCONTINUED,WNOWAIT,WEXITED,WTRAPPEDandWLINUXCLONEreturn -1 witherrnoEINVAL(kern_wait6, L1206-L1209).ECHILD, whatever the pid and with or withoutWNOHANG. The kernel finds no child or orphan before it looks atWNOHANG(L1307-L1314).waitpidaddsWEXITED | WTRAPPED(L1146), so the "no events to wait for"EINVALcannot happen.wait4copies it out only when a child was reaped (L771-L772).wait4a cancellation point. No cancel request is ever pending here (Thread cancellation in TechnicalDebt), so returning at once matches.waitpid.VLC (PPSA85300) is a port of VLC 3.0.24 and never has a child on the console either. Its compat layer makes
forkandvforkfail withENOSYSas "Features the PS5 doesn't have" (libc_missing.c L290-L292). Its netconf patch drops VLC's libproxy helper because "a title can't start programs (posix_spawnp crashed the app ...)" (0006-netconf-ps5-no-proxy-helper.patch L8-L11).Other titles that import
waitpid:tcgetattr(#1738).dup(#1855).VLC 0.2, from its GitHub release (its listing in the homebrew catalog is pending), relinked with
--windowsand run on Windows 10:maind70b8998:FAIL: unresolved ELF import dTnYqqLIQ6c from libkernel.prx(waitpid)main+ this PR:FAIL: unresolved ELF import 0NJDcQ2B8vE from libkernel.prx(execvp, left for its own PR)VLC 0.1 stops at the same two imports.
Tested
guest_waitpidtest, registered in ctest with a 20 s timeout. Every case is run twice, once with a status pointer and once with a null one.errnois cleared before each call, and every call must return -1 and leave the status untouched.WNOHANG | WUNTRACEDandWNOHANG | WLINUXCLONE, and all known bits. Every call must giveerrno10 (ECHILD).EINVAL).15.2.0posix-14.0.0-ucrt-r7), Release, merged withmaind70b8998: passes (--repeat until-fail:3), and so does the full suite. The NID-patchedlibkernel.prxexports the NID.ANYPS5_ENABLE_SPIRV_TOOLS=ON, merged withmaind70b8998: passes (--repeat until-fail:3), and so does the full suite. The NID-patchedlibkernel.prxexports the NID.WNOHANG;EINVAL;WNOHANG,WNOWAIT,WTRAPPEDorWLINUXCLONE, or accepting 0x40, 0x80 or 0x40000000;EINVALchecked only for pid -1, orWNOHANG | WUNTRACEDrejected;errnoalone, or returning 0 forWNOHANG;ESRCHfor a positive pid, orEINVALfor a process group;errnovalues off by one.tools/check_conventions.pyandtools/check_test_registration.pypass.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T09:32:44Z.
Progress report (
ddcb251→8de5e70)➖ System libraries: 85.77% (+0.0%, +1 implemented functions)
✅ 1 implemented
waitpid_nid_postfixImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T09:53:05Z.
I reviewed the full diff and checked the behavior against the cited FreeBSD implementation.
waitpidaddsWEXITED | WTRAPPEDbefore callingkern_wait6; that path rejects unknown options and option sets with no wait events before scanning children, then returnsECHILDwhen no child matches.sys_wait4copies status only after a successful nonzero child result. Those paths support this implementation’s option check,ECHILDresult and untouched status when the title has no children (kern_exit.c, option validation and child scan, status copyout).The full diff has useful option, pid-form and untouched-status coverage, and no duplicate open PR implements
waitpid. The current PR base is stilld9484c71while currentmainis3bd74c15; please rebase and refresh the tested-base note before approval. The latest Actions run skips full Linux/Windows builds under the manual Build policy; the targeted runs in the description provide the available runtime evidence.Imported from boykopovar/AnyPS5. Originally posted by LuisBiceps on 2026-10-09T14:18:32Z.
Thanks for checking it against
kern_wait6. I brought the branch up tomaind70b8998with a merge rather than a rebase, so the commits you reviewed are unchanged; it had no conflicts and the diff is the same four files. The description now uses that base:waitpidonmaind70b8998and reachexecvpwith this PR (Windows 10).guest_waitpidpasses--repeat until-fail:3on the merged head on Windows 10 and Ubuntu 26.04, and so do the full suites.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:15:02Z.
Two things before this can go in:
waitpidreturns -1 with ECHILD (EINVAL for unknown options): nothing here creates a child process; child processes would need a realwaitpid." The FreeBSD links can stay in the description.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T01:55:10Z.
Checked on current
mainee501326with this PR (72a9ca47) merged (clean), Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC from WinLibs), Release.guest_waitpidpasses 5/5 on both (--repeat until-fail:5); no CRT assertion dialog on Windows.waitpidonmainand gets past it on both:app.elf: symbol lookup error: app.elf: undefined symbol: 0NJDcQ2B8vE(execvp)FAIL: unresolved ELF import 0NJDcQ2B8vE (execvp) from libkernel.prxImported from boykopovar/AnyPS5. Originally posted by SCD28 on 2026-10-10T08:03:49Z.
I rebuilt the PR changes on current upstream
mainwithout the merge commit requested in review.I also shortened the
TechnicalDebt.mdentry to one sentence and moved theguest_waitpidCMake registration away from #1908's insertion point. The overlap is textual only; no #1908 code is included and there is no functional dependency between the two PRs.Tested on Linux / WSL2 Ubuntu 24.04:
libkernelbuild: passguest_waitpid_testsbuild: passguest_waitpid --repeat until-fail:5: 5/5 passguest_kernel_errors: passtools/check_conventions.py --base upstream/main: passtools/check_test_registration.py: passgit diff --check: passAI-assisted: yes. (Codex)
Clean branch:
SCD28/AnyPS5:assist/pr-2123-waitpidFeel free to cherry-pick or reuse the branch if useful. I can keep it rebased on current
mainif needed.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:09:25Z.
Rebased onto
main(merge commit dropped) and shortened the TechnicalDebt entry to one sentence, as requested. Two trivial conflicts inProcess.cpp(next tosystem/_exit) resolved by keeping both.Checked on the rebased head: build + ctest of libkernel/libs green, including
guest_waitpid; without the change the test does not link (waitpidundefined); behaviour matcheskern_wait6as described. Merging once CI is green.