code wiki / _hdl_build / nx_drill_hang.nx
nx_drill_hang.nx source
↩ module page · 18 lines · 816 B
1// nx_drill_hang.nx -- deterministic HANG FIXTURE for the crash-drill gate (nx_revive_gate).
2// Exists ONLY so the drill can prove nx_boot_revive's watchdog reaps a hung organ run.
3// Unarmed (no /tmp/nx_drill_hang_arm file): exits 0 immediately, so the normal
4// build-and-run lane (nx_sov_build_run) completes instantly. Armed: sleeps in a BOUNDED
5// loop (never a permanent zombie even if leaked) until the watchdog SIGKILLs it.
6// license_tier: ORIGINAL
7import "nx_syscalls.nx"
8
9const DH_BOUND_SEC: i64 = 600 // upper bound on the armed hang; drill kills at its B budget long before
10
11func main() -> i64 {
12 let fd: i64 = sys_openat_rd("/tmp/nx_drill_hang_arm" as *u8)
13 if fd < 0 { return 0 }
14 sys_close(fd)
15 var i: i64 = 0
16 while i < DH_BOUND_SEC { sys_sleep_ms(1000); i = i + 1 }
17 return 0
18}