MingaClaudeBridge.OsProcess (minga_claude_bridge v0.1.0)

Copy Markdown View Source

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.

Summary

Functions

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

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

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.

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

Types

signal()

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

Functions

alive?(pid)

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

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

signal(pid, signal)

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

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

terminate(pid, grace_ms)

@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(pid, ms)

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

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