Bash.JobProcess (Bash v0.6.0)

Copy Markdown View Source

GenServer wrapping a background OS process.

Each background job is managed by a JobProcess GenServer which:

  • Starts and monitors the OS process via CommandPort
  • Accumulates stdout/stderr output preserving order
  • Notifies the Session on status changes (done, stopped)
  • Supports foregrounding (blocks caller until completion)
  • Handles signals (SIGSTOP, SIGCONT, SIGTERM, etc.)

Lifecycle

  1. Started by Session via start_link/1
  2. Spawns OS process via CommandPort
  3. Spawns reader tasks for stdout/stderr that send messages back
  4. On process exit, notifies Session and transitions to :done
  5. Can be foregrounded (caller blocks until done)
  6. Can receive signals (kill, stop, continue)

Summary

Types

t()

@type t() :: %Bash.JobProcess{
  await_start_from: term(),
  command_string: String.t(),
  env: [{String.t(), String.t()}],
  excmd_process: pid() | nil,
  foreground_from: GenServer.from() | nil,
  job: Bash.Job.t(),
  last_signal: term(),
  os_pid: pos_integer() | nil,
  output_collector: term(),
  session_pid: pid(),
  stderr_reader: pid() | nil,
  stderr_sink: term(),
  stdout_reader: pid() | nil,
  stdout_sink: term(),
  working_dir: String.t()
}