feat(libkernel): implement sigaction #1916
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1916"
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 johnmaia on 2026-10-08T23:36:31Z.
What
Implements
sigaction(libkernel, NIDKiJEPEWRyUY). @hikazey reports in #1578 that EVO-PLAYER PPSA99039 v0.11.0 stops here once its earlier imports resolve (#1838, #1634, #1714, #1641, #1857 merged locally). At start-up,projects/evoplayer/main.cppinstalls:SIGSEGV,SIGBUSandSIGABRT(SA_SIGINFO | SA_NODEFER);SIGTERM,SIGINTandSIGHUP(flags 0).struct sigaction, which is the handler union at 0,sa_flagsat 8, the 128-bitsa_maskat 12, and 32 bytes in all.static_asserts pin it.oact.kern_sigactiondoes, other signal numbers returnEINVAL, and so does any handler butSIG_DFLonSIGKILLorSIGSTOP.signalnow shares this table and recordsSA_RESTART, as FreeBSD's libcsignaldoes, so mixing the two calls reports consistent results.SA_SIGINFOon the six signalssignalalready delivers (SIGINT,SIGILL,SIGABRT,SIGFPE,SIGSEGV,SIGTERM) run exactly assignalhandlers do.SIG_IGNandSIG_DFLare applied to the host signal as before.SA_SIGINFOhandlers and the other signals (SIGBUS,SIGHUP, ...) are recorded but never called. Calling them needs FreeBSD'ssiginfo_tanducontext_t; #1431 builds the context forsceKernelRaiseException. For a signal like that,raisethrows instead of terminating the process.sa_maskand the flags are not applied to delivery. All of this is in TechnicalDebt.Overlap: none on exports. #1431 changes signal masks and exception delivery in other files (
Exception.cpp,Thread.cpp), notSignals.cpp.Tested
guest_signals, extended:oactaftersignal(SIGTERM, SIG_DFL)reportsSA_RESTART.SIGTERMhandler with a mask in words 0 and 3 is delivered byraise, and round-trips throughoact.signalreturns the handlersigactionset, and the reverse.SA_SIGINFOhandlers on 10, 1, 64 and 128 round-trip.raise(SIGABRT)with anSA_SIGINFOhandler throws.SIG_DFLon 9 and 17 succeeds.actandoactare accepted.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)🤖 Generated with Claude Code
https://claude.ai/code/session_01DwFnKjMxmwGDWiuYYf1v4D
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T23:36:54Z.
Progress report (
c9d4261→ab658fc)➖ System libraries: 85.63% (+0.0%, +1 implemented functions)
✅ 1 implemented
sigaction_nid_postfixImported from boykopovar/AnyPS5. Originally posted by rmz-24 on 2026-10-08T23:57:28Z.
Ran this on a title, since the PR says no title was run.
Windows 11, WinLibs GCC 15.2.0 r7, Release,
--windowsrelink. EVO-PLAYER PPSA99039 v0.11.0 (release zip, SHA256 checked against the release'sSHA256SUMS.txt). Base ismainf1451396with #1838, #1634, #1714, #1641 and #1857 merged locally, the same set as in #1578.FAIL: unresolved ELF import KiJEPEWRyUY from libkernel.prx(sigaction).FAIL: unresolved ELF import DRGXpDDh8Ng from libkernel.prx(lstat).guest_signalspasses on the same build.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-09T00:14:20Z.
Checked with EVO-PLAYER v0.11.0 built from source (sainsaji/EVO-PLAYER-PS5
9715f6e: PS5 Payload SDK v0.42, pacbrew recipes and EVO's own FFmpeg 7.1.1, all from source), relinked on Linux (Ubuntu 24.04.5, RX 7600). The base wasmainf1451396plus this PR, #1838, #1634, #1714, #1641, #1857 and #1529. EVO gets pastKiJEPEWRyUYand stops later, while bringing up its resident decoders and before it opens a video output:As a control, preloading an abort-on-call stub for
KiJEPEWRyUYover this PR's export stops it atsigactionaftermain()entry, so the call is made at start-up and this PR is what gets it through.On Linux the title has 21 further unresolved imports (
atoll,lstat,socketpair,tcgetattr,madvise,mkstemp, ...) that Windows only resolves on first call. I covered those with abort-on-call stubs for this run; none was called before the Videodec2 stop.Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-09T00:39:18Z.
Review: APPROVED
Excellent, careful implementation. The POSIX contract is handled correctly: signal range validated (EINVAL outside 1–128), SIGKILL/SIGSTOP reject a non-default handler, and the disposition (handler + flags + mask) is recorded and reported back for all 128 signals even when only a subset are natively deliverable. The boundary is exactly right — SA_SIGINFO handlers and non-
signal()-delivered signals are recorded butraiseof them throws (rather than a silent no-op or wrong teardown), and the limitation is spelled out in TechnicalDebt instead of being hidden. Thesignal()path is refactored onto the sameInstall()/disposition store sosignalandsigactioncan't drift apart, and the struct layout is pinned withstatic_assert. The test matrix (query, set, raise, SIGKILL/SIGSTOP, SA_SIGINFO throw, error codes, signal↔sigaction interop) is thorough.One robustness note:
handlers[]is sized 32 whiledispositions[]is sized 129, andInstallindexeshandlers[guest]directly. That's safe today only becauseNativeSignalreturns 0 for every guest signal at/above that bound; a futureNativeSignalcase added past index 31 would be an out-of-bounds write. Anassert(native && guest < (int)(sizeof handlers / sizeof handlers[0]))(or sizinghandlerstoMaxSignal+1) would make the invariant explicit.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by johnmaia on 2026-10-09T00:51:47Z.
Thanks @klosixgaming-arch.
handlersis now sizedMaxSignal + 1, likedispositions(0c35d91c), so the bound no longer depends on which signalsNativeSignalmaps.guest_signalspasses on Linux. And thanks @rmz-24 for the Windows run with the release build.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:53:24Z.
Checked on a build of the PR merged onto current
main: full ctest 527/527,guest_signalspasses, and without the change the test doesn't link, so it exercises it. Layout andEINVALcases match FreeBSD'skern_sigaction. Confirmed on EVO-PLAYER by @rmz-24 (Windows) and the author (Linux).Added one commit: the TechnicalDebt line said
raiseof any recorded-only signal throws, but for signals without a native mapping (SIGBUS,SIGHUP, ...) it still returnsEINVALas onmain; onlySA_SIGINFOhandlers on the six delivered signals throw. Worth fixing the same sentence in the PR description. The redrelinker (windows)job ishardware_oracle, which this PR doesn't touch. Merging.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T22:59:22Z.
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/TechnicalDebt.mdL387core/libs/tests/GuestSignals.cppL48docs/dev/TechnicalDebt.mdL387docs/dev/TechnicalDebt.mdL387Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T23:20:51Z.
Checked on a build of the PR merged onto current
main: full ctest 553/553,guest_signalspasses, and without the change the test doesn't link. Layout andEINVALcases match FreeBSD'skern_sigaction; confirmed on EVO-PLAYER by @rmz-24 (Windows) and the author (Linux). Merging once CI is green on this head.