libkernel: signal() fails with EINVAL for every signal without a host equivalent (SIGPIPE, SIGHUP, SIGUSR1, ...) while sigaction() accepts them #3076
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 husseinkad on 2026-10-10T21:46:11Z.
What
signal()(core/libs/prx/libkernel/System/src/Signals.cpp) returnsSIG_ERRwithEINVALfor every guest signal that has no host equivalent: only 2, 4, 6, 8, 11 and 15 work, sosignal(SIGPIPE, SIG_IGN),signal(SIGHUP, h)andsignal(SIGUSR1, h)all fail, whilesigaction()in the same file accepts the same numbers and records the disposition. A title that ignoresSIGPIPEthe traditional way sees a failure it did not expect.FreeBSD's
signal()issigaction()withSA_RESTARTand an empty mask (neverSA_RESETHAND), and the kernel'skern_sigactionrejects only numbers outside 1..128 andSIGKILL/SIGSTOPwith a handler other thanSIG_DFL(sosignal(SIGKILL, SIG_DFL)succeeds there).Fix
A tested fix is on my fork:
husseinkad:fix/kernel-signal-unmapped-numbers(two commits onmain; PR #2760, closed by the intake check):signalfails only for numbers outside 1..128 and forSIGKILL/SIGSTOPwith a non-default handler, records the disposition of every other number in the tablesigactionuses, and returns the previous handler. Delivery is unchanged: only the six signals with host equivalents take effect or can be raised, andraise/killof the others still fail withEINVAL; in particularsignal(SIGPIPE, SIG_IGN)is recorded and succeeds but does not stop the hostSIGPIPEon Linux. TechnicalDebt is updated to say exactly that.guest_signalsgains all the unmapped numbers, 9 and 17 withSIG_DFLand with a handler,errnoleft alone on success and the stored mask and flags replaced as FreeBSD does; it fails without the change. Checked againstmain'slibkernelwith 155 signal numbers (-5 to 140 and the integer extremes) x 5 handler-chain scenarios (4,992signal()calls): the six mapped numbers and all invalid numbers are byte-identical, only the 120 previously rejected numbers change, real delivery of the six mapped signals in 8 modes is identical, and 4 to 8 threads for 2 seconds show no corruption of the table. Windows 11, WinLibs GCC 15.2.0 r7; Linux not run.AI-assisted: yes.