Repository navigation
feat(libkernel): implement sigaction - #1916
Conversation
|
Ran this on a title, since the PR says no title was run. Windows 11, WinLibs GCC 15.2.0 r7, Release,
AI-assisted: yes |
|
Checked with EVO-PLAYER v0.11.0 built from source (sainsaji/EVO-PLAYER-PS5 As a control, preloading an abort-on-call stub for On Linux the title has 21 further unresolved imports ( |
klosixgaming-arch
left a comment
There was a problem hiding this comment.
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 but raise of them throws (rather than a silent no-op or wrong teardown), and the limitation is spelled out in TechnicalDebt instead of being hidden. The signal() path is refactored onto the same Install()/disposition store so signal and sigaction can't drift apart, and the struct layout is pinned with static_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 while dispositions[] is sized 129, and Install indexes handlers[guest] directly. That's safe today only because NativeSignal returns 0 for every guest signal at/above that bound; a future NativeSignal case added past index 31 would be an out-of-bounds write. An assert(native && guest < (int)(sizeof handlers / sizeof handlers[0])) (or sizing handlers to MaxSignal+1) would make the invariant explicit.
Written with AI assistance.
|
Thanks @klosixgaming-arch. |
0c35d91 to
83eedd9
Compare
83eedd9 to
b935947
Compare
|
Checked on a build of the PR merged onto current Added one commit: the TechnicalDebt line said |
b935947 to
b11bf2d
Compare
EVO-PLAYER (PPSA99039) v0.11.0 stops at sigaction once its earlier imports resolve: it installs a crash handler for SIGSEGV, SIGBUS and SIGABRT and a quit handler for SIGTERM, SIGINT and SIGHUP at start-up. sigaction records the handler, flags and mask of signals 1 to 128 and reports them back, with FreeBSD's EINVAL cases. signal shares the table and records SA_RESTART, as FreeBSD's libc does. Plain handlers on the signals signal already delivers run as signal handlers do; SA_SIGINFO handlers and other signals are recorded only, and raise of such a signal throws. Assisted by Claude Code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DwFnKjMxmwGDWiuYYf1v4D
… dispositions Assisted by Claude Code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DwFnKjMxmwGDWiuYYf1v4D
b11bf2d to
ab658fc
Compare
|
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.
|
|
Checked on a build of the PR merged onto current |
…tion feat(libkernel): implement sigaction
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; feat(libkernel): deliver sceKernelRaiseException on Linux #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