feat(libkernel): implement sigpending #4383
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4383"
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 pushkarreddyy on 2026-10-12T08:29:44Z.
What
This pull request implements
sigpending(hpoDTzy9Yy0) inlibkernel(core/libs/prx/libkernel/System/src/Signals.cpp), imported by PS5MC (PPSA99420, Issue #1578).sigsuspendhas been dropped per maintainer review.sigpendingchecks for a null pointer withEFAULT(14), and reports the intersection of the process-wide pending signal set (Pending().words[0]) and the blocked mask of_sigprocmask(blockedMask), following FreeBSD'ssys_sigpending, while preserving guesterrnoon success.core/libs/tests/GuestSignals.cppverify null pointer rejection (EFAULT), empty pending set reporting, reporting of a blocked pending signal raised viaraise, clearing after_sigprocmaskunblocks and delivers the signal, and guesterrnopreservation.docs/dev/debt/libkernel.md.Tested
python tools/check_conventions.py --base origin/mainpassed with zero errors.git diff --check origin/main..HEADpassed with zero whitespace issues.guest_signals_testscover null rejection, empty set, blocked pending signal reporting, and clearing upon unblock.Checklist
main; no other open PR implements the same functionNotImplemented_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-12T08:37:56Z.
Progress report (
4834930→837c862)➖ System libraries: 87.89% (+0.0%, +1 implemented functions)
✅ 1 implemented
sigpending_nid_postfixImported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-12T08:48:28Z.
Thanks for picking this up. One point on
sigsuspendbefore I validate it on Windows: returning -1/EINTRimmediately is not FreeBSD's behaviour.sigsuspendinstalls the mask and blocks until a signal whose action is a handler or termination is delivered, and only then returns -1 withEINTR(kern_sig.ckern_sigsuspend). Returning at once makes a title that waits for a signal continue as if one had arrived, and the common loopwhile (sigsuspend(&mask) == -1 && errno == EINTR)spins forever. Since this runtime never delivers asynchronous signals to a waiting thread, the honest answer under the project rule ("does exactly what it should or throws") is to throw with the mask named, the same way #3580 mergedpause,sigwaitandsigwaitinfoas throwing exports.sigpendingzeroing the set is fine as long as the TechnicalDebt line says it is exact only because nothing is ever queued (blocked signals fromkill/raiseare not held either). Withsigsuspendthrowing I'd run PS5MC (PPSA99420) on Windows against the branch and post the before/after stop lines.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T09:46:03Z.
Hi @screamm,
Thank you for the review feedback!
The update is now pushed on commit \66accc415\ (rebased cleanly onto latest \origin/main\ \
2979ae37a):aise\ are not held either), and \sigsuspend\ throws naming the mask.
Ready for your Windows validation run on PS5MC (PPSA99420)! Thank you!
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T11:22:22Z.
Windows test: head
4be071b81merged onto currentmain(3d8ffeb27, clean merge). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j4: the build fails incore/libs/tests/GuestSignals.cpp, 6 errors:Cause (from the PR head, not from the merge): the
extern "C"block declaresint APS5_VABI sigpending_nid_postfix(GuestSignalSet*);andsigsuspend_nid_postfix(const GuestSignalSet*)at lines 21-22, butstruct GuestSignalSet { std::uint32_t bits[4]; };is only defined after that block (line 24). Moving the struct above theextern "C"block should fix it; I have not tried that. The remaining errors follow from the failed declarations. I did not get to runctest.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T11:41:21Z.
Hi @xXPBSXx,
Thank you very much for catching this and for running the MinGW GCC build validation on Windows!
The fix is now pushed on commit 3b8dcfe50 (rebased cleanly onto latest main
3d8ffeb27):Ready for your Windows rerun and ctest! Thank you!
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-12T11:51:48Z.
Windows check of
4be071b8merged ontomain3d8ffeb2(Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Release,BUILD_TESTING=ON):libsbuilds, butguest_signal_testsdoes not compile: the two new declarations sit in theextern "C"block abovestruct GuestSignalSet { std::uint32_t bits[4]; };(GuestSignals.cpp:21:38: error: 'GuestSignalSet' was not declared in this scope,:22:44,:221:32). A forward declarationstruct GuestSignalSet;before the block, or moving the two declarations below the struct, fixes it; with that change applied to a scratch copy of the test it passes 3/3 against this build, and the rest of the suite is 605/606 (the one failure being the unbuilt test). Conventions andgit diff --checkpass.PS5MC (PPSA99420) relinked against this build: the import audit shows
sigpending(hpoDTzy9Yy0) no longer absent (19 absent imports before, 17 now with #3606 merged), but the title's stop is unchanged,FAIL: unresolved ELF import 4X0QwvuCfjc from libkernel.prx(setrlimit, open #3980), because that import comes first; PS5MC does not importsigsuspend. So the title evidence for this PR is the audit entry, and the run-time proof needs #3980 in first. Onsigpending: returning an empty set matches this runtime, whereDispatchdrops a raised signal while it is blocked rather than queueing it; worth saying so in the TechnicalDebt line.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T12:01:45Z.
Hi @screamm,
Thank you very much for the thorough Windows 11 validation run, for testing PS5MC (PPSA99420) import audit, and for verifying the scratch test!
Everything is addressed and updated on commit
e4584d9f3:struct GuestSignalSetwas moved above theextern "C"block incore/libs/tests/GuestSignals.cpp(resolving the scope error caught on MinGW GCC). The unit tests build cleanly and pass.docs/dev/TechnicalDebt.mdto explicitly state thatsigpendingclearing the set matches this runtime whereDispatchdrops a raised signal while it is blocked rather than queueing it (in addition to blocked signals fromkill/raisenot being held).sigpending(hpoDTzy9Yy0) is confirmed resolved in the import audit (down to 17 absent imports), and the runtime execution will advance pastsetrlimitonce #3980 lands.tools/check_conventions.py --base origin/mainpasses with zero comments. Thank you!Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T13:36:53Z.
Calling on @adriadam10, @oneandonlydean, and @MarcZX100 for review clearance / merge:
All review feedback and platform verifications are complete:
sigsuspendthrows viaNotImplemented_nid_no_patchnaming the mask words, matching #3580 (pause,sigwait,sigwaitinfo).TechnicalDebt.mdupdated to documentsigpendingclearing the set matching this runtime whereDispatchdrops a raised signal while blocked.struct GuestSignalSetaboveextern "C"). @screamm verified the unit test passes 3/3 and 605/606 suite on Windows 11.sigpending(hpoDTzy9Yy0) resolved (absent imports down from 19 to 17).origin/main(ddc713fbc),mergeable: true, 0 comments in C++, all CI checks green.Ready for merge, or please let me know if any further changes are requested! Thank you!
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T15:36:34Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libkernel.mdL127-128docs/dev/debt/libkernel.mdL127-128Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-12T16:32:52Z.
Rebased cleanly on latest
origin/main(2a5eca11c):guest_signalsandguest_signal_setspassing cleanly.sigsuspendand documenting Dispatch drop semantics inTechnicalDebt.md.mergeable: true, 0 comments in C++, all conventions and CI checks passing (100% green).Ready for review clearance and merge!
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:19:47Z.
Which title reaches
sigsuspend? None is named, so please drop it. Forsigpending: #3980 is merged, and PPSA99420's next stop on main ischflags(#4379), thenmiQ1wVwSexE(getpriority, #4374) per the run on #4379, sohpoDTzy9Yy0is still not where it stops. It can go in when it is; please post that log line then.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T01:47:50Z.
@oneandonlydean Updated and rebased onto
0c3dc9ca2(5eded2c88):sigsuspend: Removedsigsuspend_nid_postfixfromSignals.cpp,GuestSignals.cpp, anddocs/dev/debt/libkernel.md.#4138(PendingSignals):sigpending_nid_postfixnow reportsPending().words[0] & blockedMaskunderPending().lock(following FreeBSD'ssys_sigpending), andGuestSignals.cppnow tests both an empty pending set and a blocked signal raised viaraisebefore and after_sigprocmaskunblocks it.Depends on: #4379, #4374in the checklist. Both #4379 (chflags) and #4374 (getpriority) are rebased on currentmain; once they land, we will post thePPSA99420log line stopping athpoDTzy9Yy0(sigpending).Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:24:18Z.
Thanks for the review ping. I checked the current PR and its dependency state. I can't clear it for merge yet: #4379 and #4374 are both still open, and the earlier title trace says PPSA99420 first reaches those imports before
sigpending. Once those prerequisites land, please re-run the title and share the exact next-stop log line; that will establish whether this PR now addresses the active stop. The reduced scope and test coverage look consistent with the changes requested so far, but I have not run this PR's tests locally.Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T07:31:36Z.
Linux test (Arch, GCC 16.2.1, Release), this PR's head
5eded2c88built on its own:guest_signalsaborts.main's version of the test passes on the same machine.With
Requirechanged locally to print its line, the failing check is the first one of the new block:Earlier in the test,
mainalready installs a handler for SIGTERM (Require(signal_nid_postfix(15, Callback) != invalid);, before thetermMaskchecks) and never resets it, so at this pointsignalreturnsCallback, notnullptr. The earlier checks of your block (null set, empty set,errnokept) pass.Resetting first should fix it, for example
Require(signal_nid_postfix(15, nullptr) == Callback);just before that line, or expectingCallbackthere. The CIlinuxjob is skipped for this PR, which is probably why it did not show up.Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-13T07:31:47Z.
Checked the suggestion: with
Require(signal_nid_postfix(15, nullptr) == Callback);added just before that line,guest_signalspasses on Linux, including the rest of your block (blocked SIGTERM reported as pending, cleared after unblock).Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-13T07:53:38Z.
@pushkarreddyy, the report isolates this to test setup: an earlier
signal_nid_postfix(15, Callback)leaves SIGTERM’s handler installed, so the later “empty set” assertion is not starting from an empty handler state. Nicolasfalesy confirmed thatRequire(signal_nid_postfix(15, nullptr) == Callback);before the new block makesguest_signalspass, including the pending/unblock checks. This points to test-state leakage; it does not indicate a failure insigpendingitself.Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T07:57:08Z.
Thanks @MarcZX100 for reviewing the scoped-down implementation and test coverage. Understood—we'll keep track of #4379 and #4374 and share the exact next-stop log on PPSA99420 as soon as those land.
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T08:02:00Z.
Thanks @nicolasfalesy and @MarcZX100 for catching and verifying the test-state leakage!
Updated in commit
837c862e2:Require(signal_nid_postfix(15, nullptr) == Callback);directly before reinstalling the handler inGuestSignals.cpp, ensuring clean handler state.main(c13dc7e6b).Ready for merge clearance once the prerequisites land!
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-13T10:42:20Z.
Windows validation with title evidence (Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build includinglibs; basemain2a2a3dc6):5eded2c8merges cleanly and the implementation looks right, butguest_signalsfails 0/3 (exit 0xc0000409) because of the test itself: line 135 of the existing test leaves signal 15 set toCallbackand never resets it, so the new block'sRequire(signal_nid_postfix(15, Callback) == nullptr);seesCallback(confirmed with an instrumented copy:REQUIRE FAILED line 214, 3/3). Changing that expectation to== Callbackmakes the whole test pass 3/3 including every sigpending assertion. Suite otherwise 687/689 (patched_librariesis broken onmainuntil #5025); conventions andgit diff --checkpass.PS5MC (PPSA99420): alone it still stops at
chflags(ixrw0h2tWuI, #4379); stacked on #4379 + #4374 it moves fromFAIL: unresolved ELF import hpoDTzy9Yy0 from libkernel.prx(sigpending) toFAIL: unresolved ELF import d7nUj1LOdDU from libkernel.prx(clock_settime, the last commit ofscreamm:feat/libkernel-ps5mc-setfrom #3632), so this is the title's stop in order and the export is reached.Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-13T14:10:49Z.
Title run with this PR: Windows 11, MinGW GCC 15.2.0 (WinLibs), Release. Built on
main3faa9cb40merged with this PR and the other open PRs that the catalog titles below need (#4377, #4379, #4374, #4383, #3798, #4863, #4105, my #5013/#5061/#5078/#5098/#5009 and the carries #5183/#5186, plus screamm'schrootbranch from #3632); every title converted from its catalog release,eboot.binkept inapp0, 60 s runs.CApplication::CreateGUI - using the ps5 windowing system) and runs 90 s.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-10-13T14:43:53Z.
@p3n1cillin Thanks a lot for testing and providing the runtime verification on Windows 11 with MinGW GCC 15.2.0! Really glad to see PS5MC (
PPSA99420) / Kodi loading cleanly and reaching its GUI without absent imports.