# `MingaClaudeBridge.OsProcess`
[🔗](https://github.com/jsmestad/minga-claude-bridge/blob/main/lib/minga_claude_bridge/os_process.ex#L1)

Signals an operating-system process by pid and stops it within a bounded time.

The pid is an integer the BEAM read from `Port.info(port, :os_pid)`. It is passed to `kill` as a separate argument with no shell, so nothing is interpolated into a command line.

`terminate/2` sends SIGTERM, waits up to the grace period for the process to exit, then sends SIGKILL and waits up to the same period again. It polls with `kill -0` every 20 ms. A process that already exited is not signalled.

# `signal`

```elixir
@type signal() :: :term | :kill
```

# `alive?`

```elixir
@spec alive?(pos_integer()) :: boolean()
```

Returns true while `pid` exists (`kill -0` succeeds).

# `signal`

```elixir
@spec signal(pos_integer(), signal()) :: :ok
```

Sends `signal` to `pid`. Returns `:ok` even when the process is gone.

# `terminate`

```elixir
@spec terminate(pos_integer(), non_neg_integer()) ::
  :exited | :killed | :still_running
```

Stops `pid`: SIGTERM, then SIGKILL after `grace_ms`. Returns `:exited` when the process exited after SIGTERM (or before it), `:killed` when SIGKILL ended it, and `:still_running` when it outlived both waits.

# `wait_gone`

```elixir
@spec wait_gone(pos_integer(), non_neg_integer()) :: boolean()
```

Waits up to `ms` milliseconds for `pid` to exit. Returns true when it is gone.

---

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