MuonTrap.cmd
You're seeing just the function
cmd
, go back to MuonTrap module for more information.
Specs
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_base
- create a temporary path under the specified cgroup path:cgroup_path
- explicitly specify a path to use. Use:cgroup_base
, unless you must control the path.: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 (default 500 ms):uid
- run the command using the specified uid or username:gid
- run the command using the specified gid or group
The following System.cmd/3
options are also available:
:into
- injects the result into the given collectable, defaults to""
:cd
- the directory to run the command in:env
- an enumerable of tuples containing environment key-value as binary:arg0
- sets the command arg0:stderr_to_stdout
- redirects stderr to stdout whentrue
:parallelism
- whentrue
, the VM will schedule port tasks to improve parallelism in the system. If set tofalse
, the VM will try to perform commands immediately, improving latency at the expense of parallelism. The default can be set on system startup by passing the "+spp" argument to--erl
.
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}