gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitf29e2502f29e2502log: RV39 gate fixmref29e2502/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

  • f29e2502log: RV39 gate fixmre
  • ad529ac1log: m572 verdictmre
  • 1b37d404RV39 on hold: hybriel#308mre
  • f9127c68Revert "Merge branch 'rv39'"mre
  • cd39f3d3log: hybriel#308mre
  • 51341d6elog: RV39 deploy startedmre
  • c9e29e06Merge branch 'rv39'mre
  • 0f8d1fdclog: RV39 report, browser 387/2mre
  • 50249b0bRV39: reportmre
  • 10ed9581compose: HL_GC_STATS=1mre
  • 955da19bRV39: re-vendor Hybriel set day39 (source 51e921d7, bin 6b481aa7)mre
  • 64b8d1dclog: RV39 startedmre
  • 1f2df72amission RV39mre
  • 6c1936f9log+status: GC planmre
  • 2846a840log: m569 result, GC hypothesismre
  • b24cd2d5log: Anton on hl:fetch, mission 569mre
  • 7d42cac1log+status: SL1 measured, fetch stalls remainmre
  • 8e5f2ceflog: SL1 deployedmre
  • 29f34212log: SL1 deploy startedmre
  • 529dd741Merge sl1-slices: slice details repair and person fill (SL1)mre