code wiki / _hdl_build / nx_init_live.nx

nx_init_live.nx

buildroot/runtime/_hdl_build/nx_init_live.nx

8744 B143 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_init_live.nx -- GATE: REAL process supervision. Reworks nx_init (dependency-ordered start, Kahn topo) + nx_supervise (restart-with-give-up-cap) onto ACTUAL forked child processes with wait4(WNOHANG) liveness -- closing the INIT-SERVICES census gap ("real fork/wait liveness wiring"). Grounded on the banked field research (pp_init/ pp_wait/pp_zombie/pp_systemd/pp_runit): PID1 reaps children; a supervisor detects death via wait4 and restarts with backoff + a give-up cap (no restart storm). The liveness primitive is proven (nx_initlive_probe: real fork + wait4 WNOHANG detects death w/ exit code, distinguishes alive). Services (dependency-ordered): base(healthy) <- worker(crashy, the cap demo) & logger(healthy). T1 dependency-ordered start (topo): base starts before its dependents; order respected. T2 healthy services (base+logger) stay ALIVE with 0 restarts -- wait4 WNOHANG reported alive every tick (REAL). T3 the crashy worker is DETECTED dead + re-forked until the cap -> gaveup (real death-detection + restart loop). T4 teeth: the worker's (cap+1) spawns are ALL DISTINCT pids (genuine new processes) + restarts NEVER exceed cap. T5 teardown: the healthy children are blocking-reaped (real pids, no zombie left). expect_exit: 0 Sovereign: nx_syscalls (fork/wait4/poll). NEVER-BRICK: forks+reaps userspace procs, 0 firmware.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_init_live.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

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

main g_puts sys_write sys_mmap nx_topo sys_mmap ↻ nx_order_ok sys_mmap ↻ ck g_puts ↻ spawn sys_fork sleep_ms sys_poll sys_exit sys_wait4 sleep_ms ↻ g_pn sys_mmap ↻ sys_write ↻ sys_openat_append sys_write ↻ sys_close sys_exit ↻

structs

none

consts

15const ST_MAGIC_1500: i64 = 1500
22const MAXD: i64 = 4
23const ST_RUNNING: i64 = 1
24const ST_GAVEUP: i64 = 2
25const K_HEALTHY: i64 = 0
26const K_CRASHY: i64 = 1

functions

17func g_puts(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 2: ckmain calls 1: sys_write
18func g_pn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x<0{b[0]=45;sys_write(1,b,1);x=0-x} if x==0{b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0{d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0{b[i]=(48+(y%10)) as u8;y=y/10;i=i-1} sys_write(1,b,d); return 0 }
called by 1: main calls 2: sys_mmapsys_write
19func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c }
called by 1: main calls 1: g_puts
20func sleep_ms(ms: i64) -> i64 { sys_poll(0 as *u8, 0, ms); return 0 }
called by 2: spawnmain calls 1: sys_poll
29func nx_topo(ndep: *i64, dep: *i64, N: i64, order: *i64) -> i64
called by 1: main calls 1: sys_mmap
46func nx_order_ok(order: *i64, oc: i64, ndep: *i64, dep: *i64, N: i64) -> i64
called by 1: main calls 1: sys_mmap
56func spawn(kind: *i64, pid: *i64, i: i64) -> i64
called by 1: main calls 3: sys_forksleep_mssys_exit
66func main() -> i64