gitoria

calendar

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Main branchmainf9b8f918Merge branch 'calendar-vendor-day61' into mainAtlasmain/plugins/proc/README.md

2.4 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.
  39. Storage returned by `run` and process events is released after the runtime
  40. copies it, including stdout, stderr and allocated error messages. `spawn` releases prepared
  41. arguments after fork and owns its iterator as part of the child's lifetime.
  42. There is no asynchronous `run` form; `spawn` is the event-based form.
  43. After `native/build.sh`, run `python3 plugins/proc/tests/memory.py`. This Linux
  44. regression installs a counting host heap and makes 5,000 calls per command for
  45. both `run` and `spawn`: empty output, small output, 64 KiB output, and exit 7.
  46. Each batch must retain zero native blocks, keep its fd count, leave no children,
  47. and grow RSS by at most 1 MiB after warmup. It does not depend on GC timing.

Branches

Latest commits

  • f9b8f918Merge branch 'calendar-vendor-day61' into mainAtlas
  • 66341793|||PR Vendor Hybriel day61Atlas
  • 36fc596bMerge branch 'vendor-day59' into mainAtlas
  • b37cc1da|||PR Vendor Hybriel day59Atlas
  • 05665102Merge branch 'vendor-day56' into mainAtlas
  • 687296fb|||PR Vendor Hybriel day56Atlas
  • a6166d4eMerge branch 'hl-standard-3' into mainAtlas
  • 6d0eb3b0|||PR Calendar day add buttons only when signed in (Kunibert minor)Atlas
  • add4b499|||PR Make calendar day actions keyboard accessibleAtlas
  • 79e49b4dMerge branch 'hl-standard' into mainAtlas
  • e9fec7bb|||PR HL-STANDARD clean-up: typed parameters, plain locals, by-reference cacheAtlas
  • eff166a4Re-vendor complete Hybriel plugins and runtime to day44mre
  • cef81394Wait for the DST fixture page instead of an unused socketmre
  • 42434f47Check lazy-session cookies after login with a stored anonymous fixturemre
  • 728e84e3Re-vendor complete Hybriel day41 plugin directoriesmre
  • cbd7ff43Backup tar: --hard-dereference, so mpackdb sidecars are never stored as hard links (Tracker's finding)mre
  • 59d1da0acalendar: plain declarations instead of needless let in 9 files (calendar#17): 49 declarations that are never reassigned; reassigned ones and the timer closure's p stay letmre
  • f5415cf9calendar: the Style blocks in the language's nested form (calendar#16): rules named after the View's own elements with their children nested, pseudo-classes and @media nested, merged duplicate select rule; same CSS, shots identical in Chrome at 4 sizesmre
  • edb7c947calendar: the sign-in callback keeps the session it finds and signs it in (same cookie, nothing signed out; ident#28); security gate 56+4 failing → 60 passedmre
  • bf8cc0fcStyles move into their components: the shell's styles into main.hl, the events and the editors into the month view's Style block; styles.hl keeps only the theme inherit, the accent and the message line; .gitignore ignores a bin symlink too; tests/styles-shots.mjs for the before/after pixel comparemre