ExecutionPlane.Process.Containment.SystemdUser (ExecutionPlaneProcess v0.3.0)

Copy Markdown View Source

Strict Linux process containment through transient systemd user services.

The service is created with KillMode=control-group. stop/2 does not report success until systemd says the unit is gone/inactive and the cgroup is unpopulated. This reaches descendants that escape ordinary process-group cancellation with setsid(2) or reparenting.

Environment values are not placed in argv. :inherit_env accepts variable names and uses systemd-run's name-only --setenv=NAME form to copy each value from the caller.

Summary

Types

status()

@type status() :: %{
  state: :active | :inactive | :failed | :unknown,
  active_state: String.t() | nil,
  sub_state: String.t() | nil,
  result: String.t() | nil,
  control_group: String.t() | nil,
  populated?: boolean() | nil
}

Functions

available?(opts \\ [])

@spec available?(keyword()) :: boolean()

empty?(handle_or_unit, opts \\ [])

@spec empty?(
  ExecutionPlane.Process.Containment.t() | String.t(),
  keyword()
) ::
  {:ok, boolean()} | {:error, {:systemctl_status_failed, integer(), String.t()}}

start(unit, program, argv \\ [], opts \\ [])

@spec start(String.t(), String.t(), [String.t()], keyword()) ::
  {:ok, ExecutionPlane.Process.Containment.t()} | {:error, term()}

status(handle_or_unit, opts \\ [])

@spec status(
  ExecutionPlane.Process.Containment.t() | String.t(),
  keyword()
) :: {:ok, status()} | {:error, term()}

stop(handle_or_unit, opts \\ [])

@spec stop(
  ExecutionPlane.Process.Containment.t() | String.t(),
  keyword()
) :: :ok | {:error, term()}