feat(libkernel): implement kill #2543

Merged
overlordxrz-source merged 1 commit from upstream-pr/2543 into main 2026-10-10 09:21:09 +00:00
overlordxrz-source commented 2026-10-10 03:26:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by overlordxrz-source on 2026-10-10T03:26:17Z.


What

kill (W0xkN0+ZkCE, libkernel) is missing on main. ProsperoStore (PPSA99000, the homebrew store) stops at it on current main.

The call is in the store's crash reporter (crash_report.cpp). It puts the crash signal back to SIG_DFL and sends it again with kill(getpid(), signal). The import has to resolve before the title can start. The call itself only runs from an SA_SIGINFO crash handler, and main does not deliver those yet.

kill follows FreeBSD's kern_kill and killpg1 (kern_sig.c). The guest is the only guest process:

  • A signal outside 0 to 128 returns EINVAL. This is checked first, as kern_kill does.
  • Signal 0 checks that the target exists and sends nothing.
  • The caller's own pid, 0 (its process group) and minus its own pid go to the caller through the existing raise. So they run signal/sigaction handlers, honour SIG_IGN and the sigprocmask mask, and have the same limits as raise.
  • -1 returns ESRCH, because FreeBSD's broadcast skips the caller and there is no other process. Any other pid also returns ESRCH.

EPERM is never returned, since there is no other process that could refuse permission. The guest is also assumed to lead its own process group. Both points are in TechnicalDebt next to sigaction.

Log

Linux rig (x86-64 Ubuntu, lavapipe, Release), homebrew catalog run of 2026-10-09: ProsperoStore PPSA99000 stops at the unresolved libkernel import W0xkN0+ZkCE (kill). W0xkN0+ZkCE is the NID of kill (SHA-1 NID computed with tools/nid_names.py, and it matches zecoxao's aerolib.csv). Nothing else on main or in an open PR exports it. The closed #2383 only declared it as NotImplemented.

With this PR applied, PPSA99000 moves past kill, next stop = ./app.elf: symbol lookup error: ./app.elf: undefined symbol: Mv1zUObHvXI.

Tested

aarch64 Debian host. The full project can't be built here because it needs x86-64.

  • New core/libs/tests/GuestKill.cpp (guest_kill, registered for Linux and Windows like guest_signals):
    • signal 0 succeeds for the own pid, 0 and minus the own pid, and a handler is not called;
    • another pid, -1 and another process group return ESRCH for signal 0 and for SIGTERM, and nothing is delivered;
    • -1 and 129 return EINVAL, even for a pid that does not exist;
    • SIGTERM reaches a signal handler through each of the three self targets;
    • SIG_IGN is honoured;
    • an undeliverable signal (100) reports raise's EINVAL.
  • I ran the test natively against Signals.cpp (Zig 0.17 clang) and it passes. The existing GuestSignals.cpp still passes against the changed file too. Four mutants each fail the test: wrong errno for a missing pid, signal 0 delivering, pid 0 not treated as self, and negative signals accepted.
  • Signals.cpp and the test compile for x86_64-linux-gnu and x86_64-windows-gnu with -Wall -Wextra. The only warning is the existing -Wreturn-type-c-linkage from General.hpp. Both also link into an x86_64 Linux executable and a MinGW .exe. Neither was run here.
  • python3 tools/check_conventions.py passes.
  • Not run with the title.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4808366375 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2543). Originally posted by [overlordxrz-source](https://github.com/overlordxrz-source) on 2026-10-10T03:26:17Z. --- ### What `kill` (`W0xkN0+ZkCE`, libkernel) is missing on `main`. ProsperoStore (PPSA99000, the homebrew store) stops at it on current `main`. The call is in the store's crash reporter ([crash_report.cpp](https://github.com/blackbearreloaded/ProsperoStore/blob/faa3005bd2ddbeb66fe11ccfcd7aba631e603967/examples/crash-report/crash_report.cpp#L81-L90)). It puts the crash signal back to `SIG_DFL` and sends it again with `kill(getpid(), signal)`. The import has to resolve before the title can start. The call itself only runs from an `SA_SIGINFO` crash handler, and `main` does not deliver those yet. `kill` follows FreeBSD's `kern_kill` and `killpg1` ([kern_sig.c](https://github.com/freebsd/freebsd-src/blob/305c3044e0249ea24a9b4571dfa6ae319a5bcdec/sys/kern/kern_sig.c#L1836-L1951)). The guest is the only guest process: - A signal outside 0 to 128 returns `EINVAL`. This is checked first, as `kern_kill` does. - Signal 0 checks that the target exists and sends nothing. - The caller's own pid, `0` (its process group) and minus its own pid go to the caller through the existing `raise`. So they run `signal`/`sigaction` handlers, honour `SIG_IGN` and the `sigprocmask` mask, and have the same limits as `raise`. - `-1` returns `ESRCH`, because FreeBSD's broadcast skips the caller and there is no other process. Any other pid also returns `ESRCH`. `EPERM` is never returned, since there is no other process that could refuse permission. The guest is also assumed to lead its own process group. Both points are in TechnicalDebt next to `sigaction`. ### Log Linux rig (x86-64 Ubuntu, lavapipe, Release), homebrew catalog run of 2026-10-09: ProsperoStore PPSA99000 stops at the unresolved libkernel import `W0xkN0+ZkCE` (`kill`). `W0xkN0+ZkCE` is the NID of `kill` (SHA-1 NID computed with `tools/nid_names.py`, and it matches zecoxao's `aerolib.csv`). Nothing else on `main` or in an open PR exports it. The closed #2383 only declared it as `NotImplemented`. With this PR applied, PPSA99000 moves past kill, next stop = `./app.elf: symbol lookup error: ./app.elf: undefined symbol: Mv1zUObHvXI`. ### Tested aarch64 Debian host. The full project can't be built here because it needs x86-64. - New `core/libs/tests/GuestKill.cpp` (`guest_kill`, registered for Linux and Windows like `guest_signals`): - signal 0 succeeds for the own pid, 0 and minus the own pid, and a handler is not called; - another pid, -1 and another process group return `ESRCH` for signal 0 and for `SIGTERM`, and nothing is delivered; - -1 and 129 return `EINVAL`, even for a pid that does not exist; - `SIGTERM` reaches a `signal` handler through each of the three self targets; - `SIG_IGN` is honoured; - an undeliverable signal (100) reports `raise`'s `EINVAL`. - I ran the test natively against `Signals.cpp` (Zig 0.17 clang) and it passes. The existing `GuestSignals.cpp` still passes against the changed file too. Four mutants each fail the test: wrong errno for a missing pid, signal 0 delivering, pid 0 not treated as self, and negative signals accepted. - `Signals.cpp` and the test compile for x86_64-linux-gnu and x86_64-windows-gnu with `-Wall -Wextra`. The only warning is the existing `-Wreturn-type-c-linkage` from `General.hpp`. Both also link into an x86_64 Linux executable and a MinGW `.exe`. Neither was run here. - `python3 tools/check_conventions.py` passes. - Not run with the title. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-10 03:26:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T03:26:28Z.


Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6093288631 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2543#issuecomment-6093288631). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T03:26:28Z. --- Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
github-actions[bot] commented 2026-10-10 03:26:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T03:26:45Z.


Progress report (3d1a7d9 → 9a70477)

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

✅ 1 implemented
Library Name
libkernel kill_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6093290684 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2543#issuecomment-6093290684). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-10T03:26:45Z. --- <!-- progress-report --> ### Progress report (3d1a7d9 → 9a70477) ➖ **System libraries**: 85.75% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `kill_nid_postfix` | </details>
adriadam10 commented 2026-10-10 09:09:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T09:09:01Z.


Rebased onto current main (only conflict: the TechnicalDebt line, moved next to sigaction instead of the end of the file). kill matches FreeBSD's kern_kill/killpg1 for the single guest process; guest_kill and the signal tests pass on Linux after the rebase. Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6095978591 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2543#issuecomment-6095978591). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-10T09:09:01Z. --- Rebased onto current `main` (only conflict: the TechnicalDebt line, moved next to `sigaction` instead of the end of the file). `kill` matches FreeBSD's `kern_kill`/`killpg1` for the single guest process; `guest_kill` and the signal tests pass on Linux after the rebase. Merging once CI is green.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!2543
No description provided.