muontrap v0.4.1 MuonTrap View Source

MuonTrap protects you from lost and out of control processes.

Link to this section Summary

Functions

Executes a command like System.cmd/3 via the muontrap wrapper

Return the absolute path to the muontrap executable

Link to this section Functions

Link to this function

cmd(command, args, opts \\ []) View Source
cmd(binary(), [binary()], keyword()) ::
  {Collectable.t(), exit_status :: non_neg_integer()}

Executes a command like System.cmd/3 via the muontrap wrapper.

# Options

  • :cgroup_controllers - run the command under the specified cgroup controllers. Defaults to [].
  • :cgroup_path - use the specified path for the cgroup
  • :cgroup_sets - set a cgroup controller parameter before running the command
  • :delay_to_sigkill - milliseconds before sending a SIGKILL to a child process if it doesn't exit with a SIGTERM
  • :uid - run the command using the specified uid or username
  • :gid - run the command using the specified gid or group

See System.cmd/3 for additional options.

# Examples

Run a command:

iex> MuonTrap.cmd("echo", ["hello"])
{"hello\n", 0}

The next examples only run on Linux. To try this out, create new cgroups:

$ sudo cgcreate -a $(whoami) -g memory,cpu:muontrap

Run a command, but limit memory so severely that it doesn't work (for demo purposes, obviously):

iex-donttest> MuonTrap.cmd("echo", ["hello"], cgroup_controllers: ["memory"], cgroup_path: "muontrap/test", cgroup_sets: [{"memory", "memory.limit_in_bytes", "8192"}])
{"", 1}
Link to this function

muontrap_path() View Source
muontrap_path() :: binary()

Return the absolute path to the muontrap executable.

Call this if you want to invoke the muontrap port binary manually.