Chapter 6

Processes and System

Run commands, consume output, and inspect system state.

Run commands safely

example.hhy
run(["git", "log", "--oneline"], { timeout: 5s })
    |> stdout_lines
    |> take(10)
    |> print

run passes argv directly and does not invoke a shell. Options include cwd, env, stdin, timeout, and max_output; stdout_lines exposes output as a lazy line stream.

System data

  • processes: a stream of process snapshots
  • system: OS, architecture, CPU, and memory metadata
  • env: a read-only view of environment variables
  • shell: explicit shell semantics, separate from run