tracker
All repositories: gitoria
1.7 KB
# hl:proc — child processes`run(command, options)` deliberately blocks the calling thread until the child exitsand its output pipes close. It returns `{ exit, lines, stderr }`; `binary = true`returns stdout as `data` (Bytes) instead of `lines`. A nonzero exit status is a result;a command that cannot start, or exceeds `timeout` (seconds), raises an Error.A signal exit is `128 + signal`.**In an event handler, `run()` stalls the whole event loop**, including HTTP routesand timer deliveries. Auto-await does not turn a blocking plugin call into a fibersuspension. This applies to the run form and a `--native` binary: `run` is theblocking twin of `spawn` (ticket #80) and waits on the calling thread.Use `run` for scripts and short synchronous work. For long jobs in a service, use`spawn` and finish the job in `on child.exit`; the timer handler returns afterstarting the child, allowing requests and subsequent timer ticks to run. Keep abusy flag when jobs must not overlap:```hybrielimport { spawn } from 'hl:proc'import { every } from 'hl:time'Boolean busy = falseclock = every(2)on clock.tick() {if (busy) { return null }busy = truechild = spawn('sleep 3')on child.exit(ev) {busy = falseconsole.log('job exited: ' + ev.exit)}on child.Error(e) {busy = falseconsole.log(e.message)}}```A child that cannot start reports Error rather than exit, so release job state inboth handlers. A killed child still reports exit. Subscribe to `child.line` fortext output or `child.data` with `{ binary = true }` for byte chunks. There is noimplicit shell; use `spawnArgs(['sh', '-c', command])` to request one explicitly.`hl:proc` has no JavaScript implementation.
Branches
Latest commits
- 57d1c0dcLog: day50 retest requestmre
- 60b1f419Log: Anton #336 result, wake checkmre
- 919a18aalog: scratchmre
- 6b504440status tidymre
- 9332bd10log: DP70 livemre
- be11daa0DP70 brief fixmre
- 886a7028DP70 brief, HM67 mergedmre
- b41cdd6dMerge hm67-searchids: packed search IDsmre
- 385904eaReport HM67 matched heap measurements and gate proofmre
- e5c9b659Pack retained search IDs into UTF-8 bytesmre
- 62a5f6c7HM67 brief, HM66 mergedmre
- b32b8440Merge hm66-catalogindex: packed catalog indexmre
- 2db0f7adReport HM66 heap measurements and validationmre
- 6ce15623Pack catalog lists and membership maps in UTF-8 bytesmre
- 71134e21HM66 briefmre
- ed4cbab2status timemre
- e982c26dlog: HM65 mergedmre
- 6e72f9d1Merge hm65-fields: episode boot scan reads three fieldsmre
- 07a5c883HM65 report measured field projection and complete validationmre
- 0eab858fRead only catalog date fields during the episode boot scanmre