# `NetRunner.Process`
[🔗](https://github.com/nyo16/net_runner/blob/v1.2.2/lib/net_runner/process.ex#L1)

GenServer managing a single OS process lifecycle.

Handles read/write on pipes, graceful shutdown, and exit status tracking.
Uses NIF-backed async I/O with `enif_select` for backpressure.

## PTY mode

Pass `pty: true` to get a pseudo-terminal. This is for **interactive and
long-running programs** (shells, REPLs, curses apps). Key differences from
pipe mode:

  * No independent stdin close — the PTY is a single bidirectional FD.
    Use `kill/2` to terminate the process.
  * The terminal echoes input back, so reads include what you wrote.
  * Fast-exiting commands may lose output if you don't read immediately —
    the PTY buffer is torn down when the slave side closes.
  * For simple commands, use pipe mode (the default).

# `alive?`

Check if the process is alive.

# `await_exit`

Wait for the process to exit. Returns `{:ok, exit_status}`.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `close_stdin`

Close stdin pipe.

# `kill`

Send a signal to the OS process.

# `os_pid`

Get the OS PID.

# `read`

Read from stdout. Blocks until data available or EOF.

# `read_stderr`

Read from stderr.

# `set_window_size`

Set PTY window size (rows, cols). Only works in PTY mode.

# `start`

# `start_link`

# `stats`

Get accumulated stats.

# `stderr_tail`

```elixir
@spec stderr_tail(GenServer.server()) :: binary()
```

Returns the retained tail of consumed stderr.

In the default `:consume` stderr mode, stderr is drained to keep the child
from blocking on a full pipe; only the most-recent `:stderr_tail_bytes`
bytes (default 8 KB) are retained and returned here. Useful for diagnosing
why a command failed.

The tail is raw bytes and may begin mid-character if stderr was truncated,
so treat it as diagnostic text rather than guaranteed-valid UTF-8. Returns
`""` in `:disabled` mode.

# `write`

Write to stdin.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
