code wiki / (root) / nx_orphan_reap.nx

nx_orphan_reap.nx

buildroot/runtime/nx_orphan_reap.nx

8820 B148 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_orphan_reap.nx -- reap ORPHANED GATE DAEMONS that survive a killed gate, by cmdline needle. WHY THIS EXISTS (measured 2026-08-01): nx_cms_tls_gate forks an admin AND a TLS front, then kills them in its own teardown. When /api/gate_run hit its 12s deadline the gate's PARENT was killed before teardown ran, so both daemons survived holding ports 8086/8447. Every later run then logged BIND-FAIL and the gate reported 1/5 -- four TLS rows red -- for a reason that had nothing to do with TLS. ★A GATE KILLED BY A DEADLINE SKIPS ITS TEARDOWN, AND ITS ORPHANED DAEMONS POISON EVERY LATER RUN. Nothing existed to clean them up: proc_kill_by_name was a LIBRARY with no CLI. ⛔NEVER-BRICK GUARDS (rule 26; this verb is destructive BY DESIGN so the guards are structural): G1 the needle must be >= NR_MIN_NEEDLE chars -- a short substring matches half the process table. ★THE SUBSTRING PROCESS-MATCH TRAP HAS BITTEN THIS ECOSYSTEM BEFORE (a substring process COUNT counted its own watchdogs); the same blade cuts deeper when it kills instead of counts. G2 a DENYLIST of load-bearing names is refused outright, even if the caller asks: killing the supervisor, mgmt api, tools daemon or edge would take the host down and is never what reaping a test daemon means. G3 it REFUSES to match itself -- otherwise the reaper is its own first victim (the self-count trap, 4 prior instances, now in kill form). G4 default signal is TERM (15), not KILL: a daemon that can close its listener should be allowed to. Usage: nx_orphan_reap <cmdline-needle> [signal] Exit 0 reaped-or-none, 2 REFUSED. license_tier: ORIGINAL expect_exit:0

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_proc_ctl.nx nx_orphan_reap.nx

imports: nx_syscalls.nxnx_proc_ctl.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nr_w sys_write sys_exit nr_len nr_n sys_mmap sys_write ↻ nr_denied nr_len ↻ pc_contains pc_contains ↻ pc_atoi sys_mmap ↻ nr_floor pc_read_cmdline sys_openat_rd sys_read sys_close proc_kill_protected pc_slen sys_openat_rd ↻ sys_mmap ↻ sys_getdents64 dirent_reclen dirent_name pc_atoi ↻ pc_read_cmdline ↻ pc_contains ↻ pc_line_protected pc_contains ↻ nx_kill sys_close ↻ sys_munmap

structs

none

consts

25const NR_MIN_NEEDLE: i64 = 10
26const NR_SIG_TERM: i64 = 15
27const NR_SELF: *u8 = "nx_orphan_reap"
28const NR_DENY_CAP: i64 = 8192
29const NR_PROT_CONF: *u8 = "knowledge/status/protected_procs.conf"

functions

34func nr_floor(d: *u8) -> i64
called by 1: main
41func nr_w(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
called by 1: main calls 1: sys_write
42func nr_n(v: i64) -> i64
called by 1: main calls 2: sys_mmapsys_write
54func nr_len(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
called by 2: nr_deniedmain
57func nr_denied(needle: *u8) -> i64
called by 1: main calls 2: nr_lenpc_contains
70func main(argc: i64, argv: *i64) -> i64