Trebejo.Proc (Trebejo v2.0.0)

Copy Markdown View Source

Process and executable utilities (shell-based operations).

Shell-dependent operations: process listing, signalling, lsof, fuser, and log access. For command availability and VM introspection use Apero.Proc directly.

All command execution is routed through Trebejo.Util with arg lists — never interpolated into shell strings — to prevent shell injection.

Summary

Functions

Lists processes using a specific file or port (fuser wrapper).

Sends a signal to a process by PID.

Shows recent logs for a process via journalctl (Linux systemd) or log (macOS).

Lists files opened by a process (lsof wrapper). Linux/macOS only.

Lists running processes (cross-platform via ps).

Functions

fuser(target)

@spec fuser(String.t()) :: {:ok, [non_neg_integer()]} | {:error, term()}

Lists processes using a specific file or port (fuser wrapper).

kill(pid, signal \\ :term)

@spec kill(non_neg_integer(), atom()) :: :ok | {:error, term()}

Sends a signal to a process by PID.

logs(service, opts \\ [])

@spec logs(
  String.t(),
  keyword()
) :: {:ok, String.t()} | {:error, term()}

Shows recent logs for a process via journalctl (Linux systemd) or log (macOS).

lsof(pid)

@spec lsof(non_neg_integer()) :: {:ok, [String.t()]} | {:error, term()}

Lists files opened by a process (lsof wrapper). Linux/macOS only.

ps(opts \\ [])

@spec ps(keyword()) :: {:ok, [map()]} | {:error, String.t()}

Lists running processes (cross-platform via ps).