feat(libkernel_sys): implement wait3 and wait4 #9162
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9162"
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 yabanana on 2026-10-21T14:05:00Z.
What
Replace the wait3/wait4 discovery stubs with typed public declarations and one shared wait backend. wait3 selects any child; wait4 passes the selection through. The integration with main's new posix_spawn support retains option validation, guest child-status translation and no-child/WNOHANG output preservation.
Linux wait4 collects the actual child's resource usage and converts it through the same field conversion as getrusage. Status and resource outputs use the existing checked guest writes. Windows reaps supported children when usage is null; resource accounting for a completed child is unimplemented and throws before closing its handle or removing it from the registry. The child remains recoverable by a later supported wait. This limitation is recorded in technical debt; no successful accounting result is fabricated.
The prior single-process description no longer applies after main added child creation. The updated fixture covers real child exit, WNOHANG, returned resources and invalid output pointers, in addition to no-child and option precedence. Linux INT_MIN follows the shared provider's host ESRCH case, documented by Linux wait(2); this is not a PS5 selector-error claim.
Export/NID presence: PS5 SDK stub table. Signatures and wait3/wait4 relationship: FreeBSD 11.4 wait(2). Console behaviour is unverified.
Tested
11 November update at
289b8c3cd55c86588f55266cda63e5e9834b0e14. Merged mainbf8094d980and retained the wait accounting entry alongside upstream's revised debt notes. The integration preview is clean against54c20307dc. All 12 focused Linux executions pass, including both wait3/wait4 library modes and the process suites. Tested with SHA256-verified binaries built with GCC 13.3 and run in a full Alpine 6.12.110 x86_64 kernel under QEMU TCG with SMAP off. All 39 web tests, conventions and whitespace checks pass. Hosted checks are pending for this head.9 November refresh at
c5f45829697e7f0c22d063232789a42bf612b461withmain67092e70b5211ed86d7a15e22cd10bca651901f5merged. The merge retains upstream’s macOS thread accounting and uses the shared ResourceUsage conversion for getrusage and wait4. The four prior relinker jobs failed on web_library_assets. I reproduced the missing mimalloc fixture on their base5299939without the PR. The refreshed branch includes upstream fix0c4dc6db47.12 focused Linux full-kernel executions pass, including both wait modes, posix_spawn and getrusage. The macOS x86_64 syntax check of Process.cpp passes with the existing C-linkage warnings. All 39 web packaging tests, conventions, whitespace and the public-header audit (407 libraries and 33,818 exports) pass. Linux results use GCC 13.3 and a full Alpine 6.12.110 kernel under QEMU TCG with SMAP off, with fresh SHA256-verified binaries. macOS checks use macOS 27.3 and Apple clang 21 on ARM64 with an x86_64 target. New hosted checks are pending.
6 November: head
75950dc455113913a6913c363547176964fe2ad1resolves the sole current-main conflict by adopting upstream maintainer commitdf959bf14bwith its authorship. MulxLoweringTests.cpp now exactly matches maine64c194c43. The wait provider is unchanged. Fresh macOS27.2/Appleclang21 Release x86_64 build through Rosetta passes MULX10 consecutive times (5.15s total), retaining all flag checks, cases, generated instructions and timeouts. Current-main merge preview, conventions and whitespace pass. This resolves the diagnostic conflict; the historical runner mismatch still has no demonstrated cause. New hosted CI is pending.4 November update: head
350fa008de66b026ff5593f219c7a8923b72310c, mainb11c7bf84fintegrated without history rewrite. The write-watch CMake conflict keeps the new fault-ahead-off registration and exactly one execute-fault/read-fault loop. 12/12 focused Linux full-kernel executions pass, including patched/unpatched wait3/wait4 and posix_spawn/getrusage. Native ARM64 macOS27.2/Apple clang21 standalone write-watch configure/build passes; all25 tests pass three times:75 executions, zero skips. Public-header ownership audit406 libraries/28,350 exports, conventions and whitespace pass.Linux qualification: GCC13.3 cross on ARM64 Ubuntu24.04, Alpine6.12.110/QEMU8.2.2TCG cpu=max,smap=off,2vCPUs1536MiB, SHA256-verified binaries. Newly required libSceNet/NetCtl are included in the final VM run; initial packaging loader failures remain excluded. Windows child accounting and previous SMAP/MULX limitations are unchanged. New hosted results remain required for this head. The separate
_wait4exports in libkernel_sys/libkernel_web remain future work; the contributor's firmware wrapper observations do not qualify their full semantics.Write-watch CI configuration fix: head
b2ec092c244ff8d0b1849287c0dfc75ad2073c8aremoves the second identical execute-fault/read-fault registration loop from core/libs/tests/write_watch/CMakeLists.txt (five deleted lines). The failed hosted job stopped during CMake configuration with duplicate test-name errors; build and execution were skipped. The same duplicate was present on mainb1b5353cfc. Local pre-fix configuration reproduces both errors. After the fix, configure/build pass and all 18 tests pass three times:54 successful executions, zero skips, including both fault cases. macOS27.2, Apple clang21, native arm64 Release; same --repeat until-fail:3 command as CI. Test bodies, assertions and 30-second timeouts are unchanged. Conventions and whitespace pass. Fresh hosted CI on this head is still pending.30 October head
f95d08cc1252a7a5e64c6920f06e2ac09e88816e, tested maine471817c68d4e1b1e44b0ce369ed88bafe4ae8ed, integrated by normal merge. The debt conflict retains both the Windows child-accounting refusal and upstream sceKernelGetUpdVersion limitations. 12/12 focused Linux full-kernel executions pass, with 8 common suites also passing on the separately built main; main's four wait3/wait4 fixture cases still terminate with their named NotImplemented exception (expected baseline non-passes). Full public-header compilation passes: 374 libraries / 14,864 exports. 519/519 local macOS x86_64 relinker tests pass (macOS 27.2, Apple clang 21, ARM64 host/Rosetta, Release, parallel 4). Conventions and whitespace pass.The previously queued diagnostic-head hosted job completed successfully on
f2349e7cd0:489/489, MULX2.11s. This removes that red result on the diagnostic head but does not establish the cause of the original flag mismatch. Operand/flag diagnostics remain intact; no flag assertion was weakened. This new merged head still needs its own hosted/full maintainer CI.Linux runtime qualification remains GCC 13.3, Alpine 6.12.110/QEMU system 8.2.2 TCG cpu=max,smap=off,2 vCPUs, 1536 MiB, SHA256-verified fresh binaries. Windows resource accounting and earlier SMAP-on limitations remain. Earlier evidence below retains its original revisions.
29 October refresh: head
71b26b9ff0aa77f70c539c02b006cff6168cc314, integrated mainf7e84c4cf1609cc10bac95a44cd431805e5ebc8a, preserving published ancestry. Main's Apple guard around host-to-guest wait-signal translation is retained inside the shared backend.The exact current-base comparison uses separately built main and candidate libraries. Eight common kernel/process suites pass on each (including posix_spawn/getrusage). The same wait3/wait4 executable is additionally run against each revision, in both patched/unpatched modes: all four candidate cases pass; all four base cases terminate with the named wait3/wait4 NotImplemented exception (exit 134), because main does not implement these APIs. These base runs are expected non-passes, not a claim that main passes the new suite. Candidate total: 12/12 successful executions.
Complete public-header audit/compilation passes: 373 libraries / 13,451 exports; conventions and whitespace pass. GCC 13.3, Alpine 6.12.110, QEMU system 8.2.2 TCG, cpu=max,smap=off, two vCPUs, 1536 MiB; SHA256-verified binaries. No new macOS/native Windows execution; Windows child-accounting refusal and the previously observed SMAP-on laboratory fault remain limitations. Earlier reports below retain their original revisions.
28 October refresh: head
0b4e1fff09cddf4672dd628e1723e80eca1f3b84, mainc02d287bd0eb9fe0718940b2735811e97c2eb509integrated by normal merge, preserving published ancestry. 12/12 focused Linux full-kernel executions pass on SHA256-verified binaries (GCC 13.3, Alpine 6.12.110, QEMU system 8.2.2 TCG, two vCPUs, 1536 MiB, cpu=max,smap=off). Tests/assertions were not changed. With SMAP enabled, the general kernel test hits a kernel fault at the new upstream context-restore IRET and times out; this CPU profile is not qualified by this refresh. No blanket native-hardware or zero-failure claim is made. Public-header ownership audit passes (368 libraries / 13,051 exports), as does full header compilation; conventions and whitespace checks pass. Fresh supported Windows runtime/full maintainer CI remains required. Earlier results below retain their original revisions.27 October head
827eadb438b3d1162effed513dac8041657b2f32, main0d62324ce25ebe4087984b9da143779ce99e7a88merged with published ancestry retained. The CMake conflict keeps both Wait.cpp and main's new Uuid.cpp; no wait implementation or assertion was changed in this update.13/13 Linux full-kernel executions pass: wait3/wait4 in both library modes, six common kernel/filesystem regressions, posix_spawn, getrusage and main's UUID regression. This covers real child exit/resource output, WNOHANG preservation and inaccessible status/resource destinations, plus UUID behavior after the source-list merge. Copied binary SHA256s verified. The first VM packaging attempts lacked the libSceAmpr dependency newly required by the general kernel test; that environment failure is retained, and the complete dependency closure passes.
Linux x86-64 build with cross GCC 13.3 hosted on ARM64 / Ubuntu 24.04; runtime Alpine 6.12.110-0-virt under QEMU system 8.2.2 TCG cpu=max, two vCPUs, 1536 MiB. CPU execution is emulated; syscalls execute in the real guest kernel.
Public-header audit and all-library standalone/combined compilation pass: 368 libraries, 12,811 exports, using native ARM64 Python with the x86-64 cross compiler and unchanged ABI guards. Wait.cpp, Uuid.cpp and the fixture pass MinGW 13.2 UCRT syntax checks. Conventions and whitespace checks against current main pass. No unverified Windows counter mapping was introduced.
Prior negative-control and narrow Wine child-registry results remain tied to
25ebeca78e: the old wrapper loses resource output, while the Windows refusal leaves the child recoverable. They are not a new native/full-DLL run of this head. Harry's native Windows report likewise remains tied to its original integration.Please dispatch fresh full Linux/Windows CI for this head, including wait, posix_spawn, getrusage and UUID. Completed-child resource accounting on Windows remains an explicit refusal before consumption. No new native Windows, macOS, title or console claim.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-22T04:12:22Z.
Review: COMMENTED
Verified on Windows 11, WinLibs GCC 15.2.0 r7, full build (
BUILD_TESTING=ON) of this PR merged onto main6ef5a1c4c:guest_kernel_sys_wait_testsfails to link with MinGW:undefined reference to '__gxx_personality_v0'fromNidCompute.cpp.obj,Sha1.cpp.objandGuestKernelSysWait.cpp.obj.core/libs/CMakeLists.txt:44compiles everything with-fno-asynchronous-unwind-tables, and this target links the static SEH runtime (-static -static-libstdc++) without turning the tables back on. The other targets that link statically, e.g.patched_libraries_tests(core/libs/CMakeLists.txt:281-282), addtarget_compile_options(... PRIVATE -fasynchronous-unwind-tables)for that reason.target_compile_options(guest_kernel_sys_wait_tests PRIVATE -fasynchronous-unwind-tables)next to thetarget_link_optionsline in theif(MINGW)block makes it link here. The other nine changed files build cleanly; CI doesn't run the full Windows build for PRs, so this wouldn't show up there.sys_wait4/kern_wait/kern_wait6: with no child process ECHILD is the only answer for valid options (guestfork/posix_spawnstill throw on main, so nothing is faked), the unknown-option mask 0x8000003F matcheskern_wait6and libkernel'swaitpid, and status/rusage stay untouched on error as insys_wait4(checked byte by byte on the 144-byte amd64struct rusage).libkernel_sys.clists only_wait4; the PS5 SDK'ssce_stubs/libkernel_sys.cis the source that listswait3andwait4. Nit: removing the stubs leaves three blank lines at the end ofExport.Discovery.cpp.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T11:50:18Z.
Review: DISMISSED
The implementation delegates to the existing
waitpidmodel cleanly, but I found Windows test-harness blockers that should be fixed before this is mergeable:guest_kernel_sys_wait_testsdoes not receive-fasynchronous-unwind-tablesin its MinGW block. This target compilesNidCompute.cppandSha1.cppand links statically; the existing MinGW Windows review reports that it fails to link with undefined__gxx_personality_v0, and that adding the compile option fixes it. Several neighboring static test targets add this option explicitly.__errorfromlibkernel.prx(LoadFunction(...)(kernel, "__error", patched)). Issue #9616 and Windows testing on related PR #9019 report thatGetProcAddressdoes not search dependencies and__erroris exported by libc. Please load/resolve it from the correct module and run both patched and unpatched fixtures on Windows.This head is also 644 commits behind current
main; please rebase/update it and rerun the focused Linux/Windows checks and overlap/convention checks against the resulting head. CI currently marks the platform jobs skipped, so the Linux guest/VM evidence in the PR body does not establish that the Windows target builds. The current queue is over the repository's generic intake pause threshold, so keep this PR tied to its existing scoped work and do not open a generic follow-up without a title-specific current-main reproduction or maintainer exception.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T05:08:50Z.
Review: COMMENTED
The latest head
3802fb6still has both Windows fixture blockers described above:__erroris queried fromlibkernel.prxeven though the common export is provided bylibc.prx, and the statically linked MinGW fixture target lacks asynchronous unwind tables. Could you update the fixture to load the actuallibc.prxprovider and enable the MinGW unwind option, then run both patched and unpatched cases on Windows? I verified this against the current diff; these are test harness setup issues and do not challenge the proposedwait3/wait4behavior.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T07:11:48Z.
Review: DISMISSED
Re-checked — new head, changes still requested
The author’s 12/12 Linux wait-suite run and public-header audit are useful, but they use
mainc02d287bd0; currentmainhas since changed shared process and wait-export code.What I ran
0b4e1fff09cddf4672dd628e1723e80eca1f3b84against currentmainedf6804cf52c62eacafc592dd6142cb4efe5bd05.git merge-base,git merge-tree --write-tree,git diff --check, and compared current-main changes on the PR’s touched paths.Results
c02d287bd0/edf6804cf5d0a53bc5c5561e69d54b2eaba4ee574b5089c8400b4e1fff09with basec02d287bd0Unedited available command output
Negative control
Findings
Blocking
mainand rerunguest_kernel_sys_waiton both the current base and refreshed head. Current main changedwaitpidsignal translation and the libkernel_sys export/API set that this PR integrates with, so the old-base results do not validate this integration.Non-blocking
Sources
Not verified
wait3/wait4behavior after integration with currentmain.To get this to a good state
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T10:31:43Z.
Review: DISMISSED
Re-reviewed — changes still requested
The new report addresses the integration and execution request from my previous review. Exact head
71b26b9ff0aa77f70c539c02b006cff6168cc314includesmainf7e84c4cf1609cc10bac95a44cd431805e5ebc8a; the author reports the eight shared kernel/process suites passing on both separately built trees and all four candidate wait3/wait4 cases passing, with the base cases reaching the expected NotImplemented exception. The public-header audit, conventions and whitespace checks are also reported clean.I compared the exact head with current
mainbc3e33f4e334996ab9ba5cbf8544942465be18f3:aad6a290dbf155ae8f16924de00447ab7b71a72b).git diff --checkpasses and current-main conventions pass.mainsince the reported merge commit do not touch the wait implementation, wait tests, or this PR'slibkernel_sysdebt entry.The remaining gate is the requested maintainer CI result on this exact head. The relevant macOS jobs and labels are still pending, so I am keeping the review changes-requested until those checks complete. The published Linux evidence uses QEMU TCG rather than native console or macOS/Windows wait behavior; the documented Windows resource-accounting limitation remains appropriately scoped.