code wiki / _hdl_build / nx_jobserver.nx
nx_jobserver.nx
buildroot/runtime/_hdl_build/nx_jobserver.nx
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
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
structs
| none |
consts
| 15 | const K_MAGIC_1000000: i64 = 1000000 |
| 16 | const K_MAGIC_1024: i64 = 1024 |
functions
| 18 | func 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 } |
| 23 | func js_wn(v: i64) -> i64 { nxi_out(v); return 0 } |
| 24 | func 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 |
| 26 | func js_path(dir: *u8, name: *u8, out: *u8) -> i64 called by 1: main |
| 35 | func js_unlink(path: *u8) -> i64 { __syscall(263, AT_FDCWD, path, 0, 0, 0, 0) return 0 } called by 1: main |
| 36 | func js_sleep_ms(ms: i64) -> i64 |
| 46 | func js_wn_fd(fd: i64, v: i64) -> i64 { nxi_fd(fd, v); return 0 } |
| 49 | func js_run_job(reqbuf: *u8, n: i64, out_path: *u8, wdog_sec: i64) -> i64 |
| 103 | func main(argc: i64, argv: *i64) -> i64 |