feat(libkernel): implement pthread_kill #3047
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3047"
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 babyhuey on 2026-10-10T21:09:32Z.
What
Implements
pthread_kill(yH-uQW3LbX0) in libkernel. Like FreeBSD's, it returns the error number instead of settingerrno:EINVALfor a signal outside 0 to 128 andESRCHfor a null thread. Signal 0 only checks the handle. A signal to the calling thread goes throughraise, so it uses the same handlers and limits asraiseandkill. A signal to another thread throwsNotImplemented, since guest signals are not delivered to a chosen thread yet (#1431). TechnicalDebt records both limits.Ruffle (PPSA68091) stops at it on
main(catalog build,eboot.binandsce_module/libc.prxunwrapped as #2605 requires; tracked in #1578):main56fb1b3b, Linux:app.elf: symbol lookup error: app.elf: undefined symbol: yH-uQW3LbX0262c0316):app.elf: symbol lookup error: app.elf: undefined symbol: 04AjkP0jO9U(_umtx_op, #1482)With #1482's wait/wake also in place, Ruffle goes on to
0Ma-LQjv6Sowithout callingpthread_killduring start-up, so it only needs the export to be there for now.Tested
Linux (Ubuntu 24.04, GCC 13, Release) on
262c0316:guest_signalspasses 5/5 (--repeat until-fail:5). The new cases deliver signal 15 to the calling thread through its handler, check that signal 0 delivers nothing, checkEINVALfor 200 and -1 andESRCHfor a null thread, and check that a signal to another thread throws without delivering.check_conventions.pypasses. Windows 11 (MinGW-w64 GCC 15.2 from WinLibs, Release) on262c0316:guest_signals5/5 with no warnings and no crash dialog; Ruffle stops atFAIL: unresolved ELF import yH-uQW3LbX0 (pthread_kill) from libkernel.prxonmainand atFAIL: unresolved ELF import 04AjkP0jO9U (_umtx_op) from libkernel.prxwith this PR.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)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T21:09:55Z.
Progress report (
77bd928→0e88f30)📉 System libraries: 85.94% (-0.03%, +1 declared functions)
🆕 1 declared as stubs
pthread_kill_nid_postfixImported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-10T22:59:25Z.
Review: COMMENTED
The semantics here are right and better sourced than most: returning the error number rather than setting
errnois what FreeBSD does, routing a self-signal throughraisemeans it inherits the same handlers and limits askill, and the test'sreceived == 0check after the other-thread throw proves no signal leaked while the not-implemented path was taken. The title is named and both limits are in the debt entry, which is the whole package this tree asks for.One small thing I would change: both return values already have names in this tree.
Pthread/Posix/Common.hppdefinesGUEST_ESRCH = 3,GUEST_EINVAL = 22,GUEST_EFAULT = 14andGUEST_ETIMEDOUT = 60— precisely because apthread_*function returns a guest errno rather than aSceKernelError, and that distinction is invisible inside a bare literal. UsingGUEST_ESRCHandGUEST_EINVALwould say which family is meant without the reader having to go and check.And the boundary is unpinned.
MaxSignalis 128 and the test isguest > MaxSignal, so 128 is a valid signal and 129 is not — but the test covers 200 and -1 rather than either side of the line. A case each way is a line apiece and stops the next reader re-deriving it.One practical note in case it is not on your radar: GitHub reports this PR as conflicting, so it needs a rebase onto
main. The conflict is a doc-line collision indocs/dev/TechnicalDebt.md—Signals.cppis byte-identical between your base and currentmain, which I checked before writing it down.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T23:25:03Z.
Thanks @Dextroid17, all three done. Rebased onto
main2b5d119f(the only conflict was the TechnicalDebt line next tokill, kept both), and a new commit on top returnsPosixThread::GUEST_EINVALandGUEST_ESRCHand adds the edge casespthread_kill(nullptr, 128) == ESRCHandpthread_kill(nullptr, 129) == EINVAL.guest_signalsstill passes on Linux and Ruffle still goes on to_umtx_op.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-11T01:08:23Z.
Conflicts with main in
Signals.cppafter thealarmchanges (e5ae8dfc); please rebase.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T01:14:20Z.
Rebased onto
main77bd928a(0e88f301). The only conflict was the include list inSignals.cpp, where I kept both<string>and<thread>.guest_signalspasses 5/5 on Linux, and Ruffle (PPSA68091) still gets pastpthread_killto_umtx_op(#1482).Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T03:39:13Z.
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.mdL519