code wiki / _hdl_build / nx_jobserver.nx

nx_jobserver.nx

buildroot/runtime/_hdl_build/nx_jobserver.nx

7082 B138 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_jobserver.nx -- PERSISTENT sovereign job-server: ONE long-lived Nishi process that runs queued commands, so the agent loop stops spawning a fresh wsl.exe + sh -c per command (the per-command churn that eats memory and triggers the .wslconfig crashes). Single-slot file queue (no shell, no quoting): - poll <dir>/nxjob.req (line1 = elf path, lines2.. = one arg each, VERBATIM) - on arrival: consume it (unlink first so it never re-runs), fork/exec the organ DIRECTLY with a WATCHDOG (kill -9 at <watchdog> seconds so a runaway can't hang/eat memory), capture stdout+stderr -> nxjob.out, write the exit code -> nxjob.res (the DONE signal, written LAST). The caller writes nxjob.req atomically (write tmp -> rename) and waits for nxjob.res. One process, file-driven, watchdogged, NO bash/PowerShell/sh. usage: nx_jobserver <queuedir> <pollbudget> <watchdog-sec> (pollbudget bounds the run for testing; a real daemon passes a large budget or is restarted by the supervisor). exit codes in res: 124=watchdog-killed, 127=execve-failed, 125=empty job, else the child's code. Sovereign: nx_syscalls only (fork/execve/wait4/dup3/clock_nanosleep/unlinkat). license_tier: ORIGINAL

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_itoa_lib.nx nx_jobserver.nx

imports: nx_syscalls.nxnx_itoa_lib.nx

imported by: nobody (leaf or entry point)

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

main sys_write js_atoi sys_mmap js_path js_w sys_write ↻ sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close js_unlink js_run_job sys_mmap ↻ sys_openat_wr sys_fork sys_dup3 sys_execve sys_exit sys_wait4 nx_kill js_sleep_ms sys_mmap ↻ sys_close ↻ sys_openat_wr ↻ js_wn_fd nxi_fd sys_mmap ↻ ccz_cat_num sys_write ↻ sys_munmap sys_close ↻ js_wn nxi_out nxi_fd ↻ js_sleep_ms ↻

structs

none

consts

15const K_MAGIC_1000000: i64 = 1000000
16const K_MAGIC_1024: i64 = 1024

functions

18func js_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
23func js_wn(v: i64) -> i64 { nxi_out(v); return 0 }
called by 1: main calls 1: nxi_out
24func js_atoi(s: *u8) -> i64 { var v: i64 = 0; var i: i64 = 0; while s[i] != (0 as u8) { let c: i64 = s[i] as i64; if c >= 48 { if c <= 57 { v = v * 10 + (c - 48) } } i = i + 1 } return v }
called by 1: main
26func js_path(dir: *u8, name: *u8, out: *u8) -> i64
called by 1: main
36func js_sleep_ms(ms: i64) -> i64
called by 2: js_run_jobmain calls 1: sys_mmap
46func js_wn_fd(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 }
called by 1: main calls 1: nxi_fd
49func js_run_job(reqbuf: *u8, n: i64, out_path: *u8, wdog_sec: i64) -> i64
103func main(argc: i64, argv: *i64) -> i64