Skip to content

feat(libc): implement siginterrupt through the sigaction libkernel registers - #8872

Open
ycbuzi wants to merge 3 commits into
boykopovar:mainfrom
ycbuzi:feat/libc-siginterrupt
Open

ycbuzi wants to merge 3 commits into
boykopovar:mainfrom
ycbuzi:feat/libc-siginterrupt

Conversation

@ycbuzi

@ycbuzi ycbuzi commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

What

libc.prx exports siginterrupt (TsrS8nGDQok, a libSceLibcInternal export in the public SDK's stub table) and runs FreeBSD 11.4's lib/libc/gen/siginterrupt.c sequence: read the signal's disposition with sigaction, set or clear the signal's bit in _sigintr and SA_RESTART in the flags, install the disposition again. EINVAL for a signal outside 1 to 128 comes from the first sigaction, as there.

libc cannot call libkernel (libkernel links libc), so this follows the pattern the pthread hooks already use: libc keeps a registered sigaction and the address of the _sigintr set (RegisterSigaction_nid_no_patch in General.hpp), and libkernel registers both from a static initializer in Signals.cpp when it loads, as RegisterPthreadOnLoad does in Thread.cpp. A call before that registration throws. The set is written outside libkernel's registration lock, as FreeBSD's libc writes it without one; the libc debt entry says so, and the libkernel signal entry from #8866 now points here.

Depends on #8866, which adds the _sigintr export and makes signal honour it; this branch is stacked on it and the diff shows both until it merges.

Tested

Windows 11, MinGW GCC 15.2.0, Release, BUILD_TESTING=ON, on main 05f9995 plus #8866:

  • guest_signals, extended: siginterrupt(30, 1) sets bit 29 and clears SA_RESTART on the installed handler, a following signal(30) registers without SA_RESTART, siginterrupt(30, 0) clears the bit and restores SA_RESTART; the same on signal 128 (bit 127) with the default disposition; 0, -1 and 129 fail with EINVAL and leave the set alone. guest_signals passes (1 of 1).
  • Revert check: with libkernel's registration commented out (everything else kept) the test fails, as siginterrupt throws; restored, it passes. It exits with 0xc0000409 and what(): siginterrupt: libkernel has not registered sigaction on the reverted build, and passes again on the restored one.
  • tools/import_audit.py on a one-line registry importing TsrS8nGDQok from libSceLibcInternal.prx against the built libraries: implemented 1, absent 0; the tool exits 1 only to note that --libs has no file named libSceLibcInternal.prx, which libc.prx serves.
  • python tools/check_conventions.py --base origin/main --head HEAD passes.
  • Not run: Linux.

Checklist

🤖 Generated with Claude Code

ycbuzi and others added 2 commits October 20, 2026 20:41
The public SDK's libkernel, libkernel_sys and libkernel_web stub tables declare _sigintr, the
sigset_t that FreeBSD's libc shares between signal and siginterrupt, and no built library
provided it (boykopovar#8846). libkernel now exports the 16-byte object, zero at start, and signal records
a handler with SA_RESTART unless its signal is in the set, as lib/libc/gen/signal.c does.

siginterrupt, which fills the set, is a libSceLibcInternal export; libc does not link libkernel
and cannot reach the dispositions, so it stays out and a debt entry for signal says so.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…gisters

siginterrupt is a libSceLibcInternal export (the public SDK's stub table has it there, not in the
kernel tables) and FreeBSD 11.4's lib/libc/gen/siginterrupt.c reads the signal's disposition,
sets or clears the signal's bit in _sigintr and SA_RESTART, and installs the disposition again.
libc cannot call libkernel, so, as the pthread hooks do, libc keeps a registered sigaction and
the address of the _sigintr set, and libkernel registers both from a static initializer when it
loads. A call before that throws; the set is written without libkernel's registration lock, as
FreeBSD's libc does. Builds on boykopovar#8866, which adds the set.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Progress report (65c393a → ec1be8a)

➖ System libraries: 53.23% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libc siginterrupt_nid_postfix

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6565 docs/dev/debt/libc.md L135
PR 7622 core/libs/prx/libc/src/Process.cpp L1

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 3965 docs/dev/debt/libc.md
PR 3986 core/libs/prx/libkernel/System/src/Signals.cpp
core/libs/tests/GuestSignals.cpp
PR 4630 docs/dev/debt/libkernel.md
PR 5021 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestSignals.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6819 docs/dev/debt/libc.md
PR 6879 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 6977 docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7081 docs/dev/debt/libc.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7201 core/libs/prx/libkernel/System/src/Signals.cpp
PR 7447 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 7509 docs/dev/debt/libkernel.md
PR 7648 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8520 docs/dev/debt/libc.md
docs/dev/debt/libkernel.md
PR 8523 docs/dev/debt/libkernel.md
PR 8546 docs/dev/debt/libc.md
PR 8550 docs/dev/debt/libc.md
PR 8553 docs/dev/debt/libkernel.md
PR 8658 core/libs/prx/libkernel/System/src/Signals.cpp
docs/dev/debt/libkernel.md
PR 8726 docs/dev/debt/libkernel.md

@MarcZX10

Copy link
Copy Markdown
Contributor

Manual review of the overlap warning: #6565 appends a libc debt entry at the end of debt/libc.md, where this PR also appends its siginterrupt entry; retain both entries when rebasing. The Signals.cpp overlap with #3986 is in blocked-signal/raise logic, while this PR adds the registration hook and updates signal for _sigintr; #7201/#7622 touch only alarm handling. Other debt-file overlaps are unrelated entries. The code overlap is line-disjoint; the only integration change I found is keeping both appended debt entries.

@ycbuzi

ycbuzi commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the overlap check. Noted for the rebase: both libc debt entries (#6565's and the siginterrupt one here) stay, and the Signals.cpp hunks (registration at the end of the file, the _sigintr line in signal) are apart from #3986's blocked-signal and raise changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs fix error Closes an issue (Fixes #N) libc libkernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

libkernel: public SDK _sigintr data object has no built provider

2 participants