feat(libkernel): accept EVFILT_SIGNAL in kevent #14886

Merged
kallmek3nny merged 4 commits from upstream-pr/14886 into main 2026-11-07 00:50:50 +00:00
kallmek3nny commented 2026-11-01 22:37:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by kallmek3nny on 2026-11-01T22:37:53Z.


What

kevent threw NotImplemented_nid_no_patch for every EVFILT_SIGNAL change. It now accepts EVFILT_SIGNAL, as FreeBSD 11.4 does. In kern_sig.c, filt_sigattach attaches the knote to the calling process and adds EV_CLEAR to it. filt_signal adds 1 to kn_data for each NOTE_SIGNAL hint whose signal is the knote's ident, and reports the knote while kn_data is not 0. tdsendsignal sends that hint with KNOTE_LOCKED(p->p_klist, NOTE_SIGNAL | sig) before it checks whether the signal is ignored or masked, so ignored and blocked signals are counted too:

  • EV_ADD stores the knote with EV_CLEAR added and fflags and data 0, as kqueue_register moves kev->fflags and kev->data into kn_sfflags and kn_sdata.
  • Each signal that raise, kill, killpg or pthread_kill sends, and each ITIMER_REAL expiry, adds 1 to data of the EVFILT_SIGNAL knote for that signal in every kqueue and triggers it. Ignored and blocked signals are counted too, as in tdsendsignal. kill with signal 0 counts nothing.
  • The knote is reported with EV_CLEAR, fflags 0, the signals counted since it was last reported in data and its udata, and then its count starts again from 0.
  • A disabled knote keeps counting and reports nothing; EV_ENABLE reports what it counted. EV_DELETE removes the knote; EV_DELETE or EV_ENABLE with no knote fails with ENOENT.
  • Signals from other sources (host faults, other processes) are not counted.

The kevent measurements entry in docs/dev/debt/libkernel.md (payload processes on a PS5, firmware 12.70) recorded that EVFILT_SIGNAL for SIGUSR1 was accepted there and still threw here. This PR rewrites that clause (line 172) to say it is accepted here, that data counts only the signals those four functions and the ITIMER_REAL expiry send, and that the counts the PS5 reports were not measured. The kqueue and kevent entry (line 167) now lists the signal filter among the filters that do not throw. Only the acceptance was measured on a PS5; the counting follows FreeBSD 11.4.

Code: Register in Equeue/src/Kqueue.cpp accepts EVFILT_SIGNAL and adds it with the new AddSignalKnote, which stores the knote with EV_CLEAR added and fflags and data cleared in both the stored event and the change. The new KqueueSignalSent, declared in Equeue/Equeue.hpp, adds 1 to data of the EVFILT_SIGNAL knote with that ident in every open kqueue and triggers it. System/src/Signals.cpp calls it in three places. Each call comes after the signal's disposition has been read, because a thread that the knote wakes can change that disposition. In raise (which kill and killpg on the calling process and pthread_kill on the calling thread go through), it runs before the ignore check. In pthread_kill on another live thread, it runs after the disposition check that marks the signal pending. In ExpireAlarm, it runs with SIGALRM before the ignore and mask checks.

Tests: SignalEvents in core/libs/tests/GuestKqueue.cpp runs with SIGUSR1 and SIGALRM ignored:

  • EV_DELETE and EV_ENABLE with no knote fail with ENOENT.
  • Adds for SIGUSR1 (with fflags 7, data 9 and a udata), SIGUSR2 and SIGALRM report no event, and neither does kill with signal 0.
  • raise, kill and pthread_kill on the calling thread with SIGUSR1 give one event with EV_CLEAR, fflags 0, data 3 and the udata, then none.
  • After EV_DISABLE, a raise reports no event; EV_ENABLE then reports one with data 1.
  • A 20 ms ITIMER_REAL gives one SIGALRM event with data 1.
  • EV_DELETE returns 0 and a second one fails with ENOENT. A raise after the delete reports no event, and a raise after close still succeeds.

Overlap: no open PR implements EVFILT_SIGNAL.

  • gh pr list --repo boykopovar/AnyPS5 --state open --search for filt_sigattach and NOTE_SIGNAL returned no PRs. EVFILT_SIGNAL returned only my #14854 (below), whose debt rewrite keeps the EVFILT_SIGNAL clause as it is on main. kevent signal added #9491 (semaphore tokens for queued waiters), and kqueue signal added #9557 (SIGIO owner of a pipe) and #12682 (cancel blocked POSIX reads). By title #9491 is unrelated; the diff search below found no signal-filter code or text in #9557 or #12682.
  • tools/pr_overlap.py reports five PRs. The first four add or remove no signal-filter code or text:
    • #7492 (wake every waiter on an equeue or kqueue) adds UserEventWakesEveryWaiter right after UserEvents in GuestKqueue.cpp (line 357 on main), where this PR adds SignalEvents.
    • #8497 (sender in the si_code of sigwaitinfo and sigtimedwait) changes the MarkPending call in pthread_kill (lines 699-700 on main), next to the line this PR adds there.
    • #12741 (macOS edge watches) rewrites debt line 167.
    • My #14832 (NOTE_LOWAT below 1) rewrites debt lines 167 and 172.
  • My #14854 (EVFILT_PROC with NOTE_EXIT on the calling process) changes the same filter check in Register and adds its own constant, add function and Register branch next to this PR's. git merge-tree of this branch with its head 575c14f9b4 conflicts in four blocks in Kqueue.cpp and on debt lines 167 and 172. Each conflict puts two additions side by side, and keeping both sides resolves it. Whichever PR merges second needs a rebase of those lines.
  • pr_overlap could not compare 39 PRs that conflict with main. I searched each of their diffs for removed code lines this PR also removes, for the same debt lines or entries, and for added or removed signal-filter text. None shares a removed code line or adds or removes signal-filter text. #7088 and #9843 also rewrite the kqueue and kevent entry (line 167), so the second to merge will need a rebase there. #3986, #7121, #9389, #12682, #12688, #12700 and #12965 share Signals.cpp or the kqueue files and change other lines.

Tested

Windows 11 Home 10.0.26300.9711, Git Bash, WinLibs gcc/g++, Ninja, Release, in the build tree configured with cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_TESTING=ON -DPython3_EXECUTABLE=C:/Python314/python.exe. No title or homebrew; only the guest tests below were run.

  • On this branch (base 5bae1a4bc2), after the code and test edits: cmake --build build --target guest_kqueue_tests guest_kill_tests guest_itimer_tests: exit 0. ctest --test-dir build -R '^(guest_kqueue|guest_kill|guest_itimer|guest_itimer_pending_default)$' --no-tests=error --output-on-failure --timeout 120: 4/4 passed.
  • After the debt edits: ctest --test-dir build -R 'public_headers' --no-tests=error --output-on-failure --timeout 120: 65/65 passed, because Equeue.hpp changed.
  • Then a full cmake --build build: exit 0. ctest --test-dir build -R '^guest_(kqueue|kqueue_cleared_race|kill|itimer|itimer_pending_default|getitimer|signals|signal_interrupt|signal_handler_mask|sigtimedwait|signal_sets|sigaltstack|raise_.*|mutex_raise_exception)$' --no-tests=error --output-on-failure --timeout 120: 30/30 passed, among them guest_kqueue, guest_kqueue_cleared_race, guest_kill, guest_itimer, guest_signals and the guest_raise_* tests. The commit 7014b28abb has the same 5 files, 87 insertions and 3 deletions as the tested working tree.
  • The previous head 0211640a74 amends 7014b28abb and changes only debt line 172 (1 insertion, 1 deletion), to shorten the EVFILT_SIGNAL clause. On it, python tools/check_conventions.py --base origin/main exited 0 with 0 errors and 2 debt-length warnings for docs/dev/debt/libkernel.md. Line 167 is 3545 characters (3537 on main) and line 172 is 4546 characters (4336 on main); both were already over 1000 characters on main. None of the 5 files changed on origin/main (0580e5c951) since the merge base.
  • The Windows CI run on 0211640a74 failed in guest_kqueue because SIGALRM expired with the default disposition. ExpireAlarm counted SIGALRM in the kqueues before it read the disposition, so SignalEvents, woken by the knote, could restore SIG_DFL first. pthread_kill on another live thread had the same order. The head 49dc637ee2 reads the disposition first in both places (Signals.cpp, 2 insertions, 2 deletions). These checks ran on 0211640a74 with that diff uncommitted. A full cmake --build build exited 0. ctest --test-dir build -R '^(guest_kqueue|guest_kill|guest_itimer)' --output-on-failure: 5/5 passed. ctest --test-dir build -R '^guest_kqueue$' --repeat until-fail:25 --output-on-failure: all 25 runs passed. On 49dc637ee2, python tools/check_conventions.py --base origin/main exited 0 with 0 errors and the same 2 debt-length warnings.
  • python tools/pr_overlap.py --branch feat/libkernel-kevent-signal: exit 2. It found 1858 open PRs and fails closed when it cannot compare every one. The manual comparison is under What.

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 under Silent stubs in their library's technical debt file
  • 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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5112275037 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14886). Originally posted by [kallmek3nny](https://github.com/kallmek3nny) on 2026-11-01T22:37:53Z. --- ### What `kevent` threw `NotImplemented_nid_no_patch` for every `EVFILT_SIGNAL` change. It now accepts `EVFILT_SIGNAL`, as FreeBSD 11.4 does. In [`kern_sig.c`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/kern_sig.c), [`filt_sigattach`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/kern_sig.c#L3784) attaches the knote to the calling process and adds `EV_CLEAR` to it. [`filt_signal`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/kern_sig.c#L3811) adds 1 to `kn_data` for each `NOTE_SIGNAL` hint whose signal is the knote's ident, and reports the knote while `kn_data` is not 0. `tdsendsignal` sends that hint with [`KNOTE_LOCKED(p->p_klist, NOTE_SIGNAL | sig)`](https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/kern/kern_sig.c#L2163) before it checks whether the signal is ignored or masked, so ignored and blocked signals are counted too: - `EV_ADD` stores the knote with `EV_CLEAR` added and `fflags` and `data` 0, as `kqueue_register` moves `kev->fflags` and `kev->data` into `kn_sfflags` and `kn_sdata`. - Each signal that `raise`, `kill`, `killpg` or `pthread_kill` sends, and each `ITIMER_REAL` expiry, adds 1 to `data` of the `EVFILT_SIGNAL` knote for that signal in every kqueue and triggers it. Ignored and blocked signals are counted too, as in `tdsendsignal`. `kill` with signal 0 counts nothing. - The knote is reported with `EV_CLEAR`, `fflags` 0, the signals counted since it was last reported in `data` and its `udata`, and then its count starts again from 0. - A disabled knote keeps counting and reports nothing; `EV_ENABLE` reports what it counted. `EV_DELETE` removes the knote; `EV_DELETE` or `EV_ENABLE` with no knote fails with `ENOENT`. - Signals from other sources (host faults, other processes) are not counted. The kevent measurements entry in `docs/dev/debt/libkernel.md` (payload processes on a PS5, firmware 12.70) recorded that `EVFILT_SIGNAL` for `SIGUSR1` was accepted there and still threw here. This PR rewrites that clause (line 172) to say it is accepted here, that `data` counts only the signals those four functions and the `ITIMER_REAL` expiry send, and that the counts the PS5 reports were not measured. The kqueue and kevent entry (line 167) now lists the signal filter among the filters that do not throw. Only the acceptance was measured on a PS5; the counting follows FreeBSD 11.4. Code: `Register` in `Equeue/src/Kqueue.cpp` accepts `EVFILT_SIGNAL` and adds it with the new `AddSignalKnote`, which stores the knote with `EV_CLEAR` added and `fflags` and `data` cleared in both the stored event and the change. The new `KqueueSignalSent`, declared in `Equeue/Equeue.hpp`, adds 1 to `data` of the `EVFILT_SIGNAL` knote with that ident in every open kqueue and triggers it. `System/src/Signals.cpp` calls it in three places. Each call comes after the signal's disposition has been read, because a thread that the knote wakes can change that disposition. In `raise` (which `kill` and `killpg` on the calling process and `pthread_kill` on the calling thread go through), it runs before the ignore check. In `pthread_kill` on another live thread, it runs after the disposition check that marks the signal pending. In `ExpireAlarm`, it runs with `SIGALRM` before the ignore and mask checks. Tests: `SignalEvents` in `core/libs/tests/GuestKqueue.cpp` runs with `SIGUSR1` and `SIGALRM` ignored: - `EV_DELETE` and `EV_ENABLE` with no knote fail with `ENOENT`. - Adds for `SIGUSR1` (with `fflags` 7, `data` 9 and a `udata`), `SIGUSR2` and `SIGALRM` report no event, and neither does `kill` with signal 0. - `raise`, `kill` and `pthread_kill` on the calling thread with `SIGUSR1` give one event with `EV_CLEAR`, `fflags` 0, `data` 3 and the `udata`, then none. - After `EV_DISABLE`, a `raise` reports no event; `EV_ENABLE` then reports one with `data` 1. - A 20 ms `ITIMER_REAL` gives one `SIGALRM` event with `data` 1. - `EV_DELETE` returns 0 and a second one fails with `ENOENT`. A `raise` after the delete reports no event, and a `raise` after `close` still succeeds. Overlap: no open PR implements `EVFILT_SIGNAL`. - `gh pr list --repo boykopovar/AnyPS5 --state open --search` for `filt_sigattach` and `NOTE_SIGNAL` returned no PRs. `EVFILT_SIGNAL` returned only my #14854 (below), whose debt rewrite keeps the `EVFILT_SIGNAL` clause as it is on `main`. `kevent signal` added #9491 (semaphore tokens for queued waiters), and `kqueue signal` added #9557 (`SIGIO` owner of a pipe) and #12682 (cancel blocked POSIX reads). By title #9491 is unrelated; the diff search below found no signal-filter code or text in #9557 or #12682. - `tools/pr_overlap.py` reports five PRs. The first four add or remove no signal-filter code or text: - #7492 (wake every waiter on an equeue or kqueue) adds `UserEventWakesEveryWaiter` right after `UserEvents` in `GuestKqueue.cpp` (line 357 on `main`), where this PR adds `SignalEvents`. - #8497 (sender in the `si_code` of `sigwaitinfo` and `sigtimedwait`) changes the `MarkPending` call in `pthread_kill` (lines 699-700 on `main`), next to the line this PR adds there. - #12741 (macOS edge watches) rewrites debt line 167. - My #14832 (NOTE_LOWAT below 1) rewrites debt lines 167 and 172. - My #14854 (`EVFILT_PROC` with `NOTE_EXIT` on the calling process) changes the same filter check in `Register` and adds its own constant, add function and `Register` branch next to this PR's. `git merge-tree` of this branch with its head `575c14f9b4` conflicts in four blocks in `Kqueue.cpp` and on debt lines 167 and 172. Each conflict puts two additions side by side, and keeping both sides resolves it. Whichever PR merges second needs a rebase of those lines. - pr_overlap could not compare 39 PRs that conflict with `main`. I searched each of their diffs for removed code lines this PR also removes, for the same debt lines or entries, and for added or removed signal-filter text. None shares a removed code line or adds or removes signal-filter text. #7088 and #9843 also rewrite the kqueue and kevent entry (line 167), so the second to merge will need a rebase there. #3986, #7121, #9389, #12682, #12688, #12700 and #12965 share `Signals.cpp` or the kqueue files and change other lines. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows 11 Home 10.0.26300.9711, Git Bash, WinLibs gcc/g++, Ninja, Release, in the build tree configured with `cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_TESTING=ON -DPython3_EXECUTABLE=C:/Python314/python.exe`. No title or homebrew; only the guest tests below were run. - On this branch (base `5bae1a4bc2`), after the code and test edits: `cmake --build build --target guest_kqueue_tests guest_kill_tests guest_itimer_tests`: exit 0. `ctest --test-dir build -R '^(guest_kqueue|guest_kill|guest_itimer|guest_itimer_pending_default)$' --no-tests=error --output-on-failure --timeout 120`: 4/4 passed. - After the debt edits: `ctest --test-dir build -R 'public_headers' --no-tests=error --output-on-failure --timeout 120`: 65/65 passed, because `Equeue.hpp` changed. - Then a full `cmake --build build`: exit 0. `ctest --test-dir build -R '^guest_(kqueue|kqueue_cleared_race|kill|itimer|itimer_pending_default|getitimer|signals|signal_interrupt|signal_handler_mask|sigtimedwait|signal_sets|sigaltstack|raise_.*|mutex_raise_exception)$' --no-tests=error --output-on-failure --timeout 120`: 30/30 passed, among them `guest_kqueue`, `guest_kqueue_cleared_race`, `guest_kill`, `guest_itimer`, `guest_signals` and the `guest_raise_*` tests. The commit `7014b28abb` has the same 5 files, 87 insertions and 3 deletions as the tested working tree. - The previous head `0211640a74` amends `7014b28abb` and changes only debt line 172 (1 insertion, 1 deletion), to shorten the `EVFILT_SIGNAL` clause. On it, `python tools/check_conventions.py --base origin/main` exited 0 with 0 errors and 2 `debt-length` warnings for `docs/dev/debt/libkernel.md`. Line 167 is 3545 characters (3537 on `main`) and line 172 is 4546 characters (4336 on `main`); both were already over 1000 characters on `main`. None of the 5 files changed on `origin/main` (`0580e5c951`) since the merge base. - The Windows CI run on `0211640a74` failed in `guest_kqueue` because `SIGALRM` expired with the default disposition. `ExpireAlarm` counted `SIGALRM` in the kqueues before it read the disposition, so `SignalEvents`, woken by the knote, could restore `SIG_DFL` first. `pthread_kill` on another live thread had the same order. The head `49dc637ee2` reads the disposition first in both places (`Signals.cpp`, 2 insertions, 2 deletions). These checks ran on `0211640a74` with that diff uncommitted. A full `cmake --build build` exited 0. `ctest --test-dir build -R '^(guest_kqueue|guest_kill|guest_itimer)' --output-on-failure`: 5/5 passed. `ctest --test-dir build -R '^guest_kqueue$' --repeat until-fail:25 --output-on-failure`: all 25 runs passed. On `49dc637ee2`, `python tools/check_conventions.py --base origin/main` exited 0 with 0 errors and the same 2 `debt-length` warnings. - `python tools/pr_overlap.py --branch feat/libkernel-kevent-signal`: exit 2. It found 1858 open PRs and fails closed when it cannot compare every one. The manual comparison is under What. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
BunnyFl commented 2026-11-02 00:17:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T00:17:45Z.

Review: APPROVED


Reviewed at 49dc637ee2, merged locally into main 66e1f7f993 (clean merge; GitHub reports it mergeable). Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, Ninja.

Checked against FreeBSD 11.4's source (release/11.4.0, source read, not run, not measured on a console):

  • sys/kern/kern_sig.c:3784-3794: filt_sigattach attaches to curproc and sets EV_CLEAR. 3811-3821: filt_signal adds 1 to kn_data for a NOTE_SIGNAL hint matching the ident and reports while kn_data is not 0.
  • kern_sig.c:2163: tdsendsignal runs KNOTE_LOCKED(p->p_klist, NOTE_SIGNAL | sig) before the ps_sigignore check, so ignored and blocked signals are counted, as this PR does.
  • sys/kern/kern_event.c: knote() calls f_event on a disabled knote too (it skips only a knote in flux, line 2131), and KNOTE_ACTIVATE (lines 202-212) only skips the queue while KN_DISABLED is set, so a disabled knote keeps counting. EV_ENABLE re-checks with f_event(kn, 0) in kqueue_register and reports the count, which matches the EV_DISABLE/EV_ENABLE case in SignalEvents.

In Signals.cpp with this PR, raise (which kill on the calling process goes through) counts before its ignore check, and pthread_kill on another live thread counts after marking the signal pending, whatever its disposition. So both paths count ignored signals, as tdsendsignal does.

What I ran

  • ctest -R '^(guest_kqueue|guest_kqueue_cleared_race|guest_signals|guest_signal_list|guest_signal_sets|guest_signal_handler_mask|guest_signal_interrupt|guest_sigtimedwait|guest_sigaltstack|guest_itimer|guest_itimer_pending_default)$' --repeat until-fail:3: 11 of 11 pass, 3 of 3 runs.
  • Negative control: main's Equeue/src/Kqueue.cpp, Equeue/Equeue.hpp and System/src/Signals.cpp with this PR's test: guest_kqueue aborts with kevent: filter -6 not implemented.
  • python tools/check_conventions.py --base upstream/main: no errors; two debt-length warnings on the kqueue and kevent and kevent measurements entries, which are already over the limit on main.

Looks good.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5730956247 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14886#pullrequestreview-5730956247). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T00:17:45Z. **Review:** APPROVED --- Reviewed at `49dc637ee2`, merged locally into `main` `66e1f7f993` (clean merge; GitHub reports it mergeable). Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0, Release, Ninja. **Checked against FreeBSD 11.4's source** (`release/11.4.0`, source read, not run, not measured on a console): - `sys/kern/kern_sig.c:3784-3794`: `filt_sigattach` attaches to `curproc` and sets `EV_CLEAR`. `3811-3821`: `filt_signal` adds 1 to `kn_data` for a `NOTE_SIGNAL` hint matching the ident and reports while `kn_data` is not 0. - `kern_sig.c:2163`: `tdsendsignal` runs `KNOTE_LOCKED(p->p_klist, NOTE_SIGNAL | sig)` before the `ps_sigignore` check, so ignored and blocked signals are counted, as this PR does. - `sys/kern/kern_event.c`: `knote()` calls `f_event` on a disabled knote too (it skips only a knote in flux, line 2131), and `KNOTE_ACTIVATE` (lines 202-212) only skips the queue while `KN_DISABLED` is set, so a disabled knote keeps counting. `EV_ENABLE` re-checks with `f_event(kn, 0)` in `kqueue_register` and reports the count, which matches the `EV_DISABLE`/`EV_ENABLE` case in `SignalEvents`. In `Signals.cpp` with this PR, `raise` (which `kill` on the calling process goes through) counts before its ignore check, and `pthread_kill` on another live thread counts after marking the signal pending, whatever its disposition. So both paths count ignored signals, as `tdsendsignal` does. **What I ran** - `ctest -R '^(guest_kqueue|guest_kqueue_cleared_race|guest_signals|guest_signal_list|guest_signal_sets|guest_signal_handler_mask|guest_signal_interrupt|guest_sigtimedwait|guest_sigaltstack|guest_itimer|guest_itimer_pending_default)$' --repeat until-fail:3`: 11 of 11 pass, 3 of 3 runs. - Negative control: `main`'s `Equeue/src/Kqueue.cpp`, `Equeue/Equeue.hpp` and `System/src/Signals.cpp` with this PR's test: `guest_kqueue` aborts with `kevent: filter -6 not implemented`. - `python tools/check_conventions.py --base upstream/main`: no errors; two `debt-length` warnings on the `kqueue and kevent` and `kevent measurements` entries, which are already over the limit on `main`. Looks good. AI-assisted: yes (Claude Code)
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!14886
No description provided.