gitoria

kunibert

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Branchhl-standard9710e39fType STANDARD as String (L10, Kunibert review)mrehl-standard/plugins/proc/README.md

1.7 KB

  1. # hl:proc — child processes
  2. `run(command, options)` deliberately blocks the calling thread until the child exits
  3. and its output pipes close. It returns `{ exit, lines, stderr }`; `binary = true`
  4. returns stdout as `data` (Bytes) instead of `lines`. A nonzero exit status is a result;
  5. a command that cannot start, or exceeds `timeout` (seconds), raises an Error.
  6. A signal exit is `128 + signal`.
  7. **In an event handler, `run()` stalls the whole event loop**, including HTTP routes
  8. and timer deliveries. Auto-await does not turn a blocking plugin call into a fiber
  9. suspension. This applies to the run form and a `--native` binary: `run` is the
  10. blocking twin of `spawn` (ticket #80) and waits on the calling thread.
  11. Use `run` for scripts and short synchronous work. For long jobs in a service, use
  12. `spawn` and finish the job in `on child.exit`; the timer handler returns after
  13. starting the child, allowing requests and subsequent timer ticks to run. Keep a
  14. busy flag when jobs must not overlap:
  15. ```hybriel
  16. import { spawn } from 'hl:proc'
  17. import { every } from 'hl:time'
  18. Boolean busy = false
  19. clock = every(2)
  20. on clock.tick() {
  21. if (busy) { return null }
  22. busy = true
  23. child = spawn('sleep 3')
  24. on child.exit(ev) {
  25. busy = false
  26. console.log('job exited: ' + ev.exit)
  27. }
  28. on child.Error(e) {
  29. busy = false
  30. console.log(e.message)
  31. }
  32. }
  33. ```
  34. A child that cannot start reports Error rather than exit, so release job state in
  35. both handlers. A killed child still reports exit. Subscribe to `child.line` for
  36. text output or `child.data` with `{ binary = true }` for byte chunks. There is no
  37. implicit shell; use `spawnArgs(['sh', '-c', command])` to request one explicitly.
  38. `hl:proc` has no JavaScript implementation.

Branches

Latest commits

  • 9710e39fType STANDARD as String (L10, Kunibert review)mre
  • 4140b664|||PR Review against HL-STANDARD and cite rule ids (gitoria#50 step 3)mre
  • 75c6888drecords: gitoria#50 step 1 connected and provenmre
  • aa6d997frecords: gitoria#50 connect plan, Anton reportmre
  • 8a190ba7Records: kunibert#18 and #15 donemre
  • 2eee9dbbMerge branch 'revendor-day44' into mainKunibert
  • e96721cb|||PR Re-vendor plugins from Hybriel day44 (hl:fetch redirect fix)mre
  • 0c67ab8cLog: kunibert repo ping provenmre
  • b6f3039cLog: kunibert repo connectedmre
  • b143c3c7CONDUCTOR: push recipemre
  • 7a1279eeRule: conductor merges own utility PRs after green reviewmre
  • 4038b3e0Log: kunibert#18 openedmre
  • 18543db1Log: day42 fetch fix, re-vendor pendingmre
  • 81a12f96Statusmre
  • 6ce706abRecords: neutral wording, split cleanupmre
  • 81a4d31bDocs: neutral wordingKunibert
  • 8205b05eRecords: #17 livemre
  • c3391204Answer fresh reviews under open threadsKunibert
  • a0f3d147Records: #16 livemre
  • 04322148Run reviews in parallel across repositoriesKunibert