Runs an external command with a file as its standard input, for
delivery to programs such as procmail, dovecot-lda, or a list
manager.
{:ok, 0, _output} = Sovite.Pipe.run(["/usr/bin/procmail", "-a", "lists"], "/tmp/message")The command is run directly, never through a shell, so its arguments
are passed exactly as given. It starts with an empty environment, apart
from PATH and the :env option, in the given working directory, and
is killed when it runs longer than the timeout. Standard output and
standard error are collected together, up to a limit, for error
reports.
To confine the command further, put a sandbox program in front of it,
such as systemd-run --pipe --wait --collect -p DynamicUser=yes or
bwrap: they take the command as their arguments and pass standard
input through.
Summary
Functions
Runs command (the program, an absolute path, and its arguments) with
the file input as its standard input.
Types
@type error() :: :timeout | File.posix()
Why the command did not run to its end.
Functions
@spec run([String.t(), ...], Path.t(), keyword()) :: {:ok, non_neg_integer(), binary()} | {:error, :timeout, binary()} | {:error, error()}
Runs command (the program, an absolute path, and its arguments) with
the file input as its standard input.
Returns {:ok, exit_status, output} when the command ran: an exit
status above 128 means it was killed by signal status - 128. Returns
{:error, :timeout, output} when it was killed for running too long,
and {:error, reason} when it could not be started (:enoent,
:eacces).
Options
:env- environment variables, a map of names to values.PATHdefaults to/usr/local/bin:/usr/bin:/bin.:directory- the working directory. Defaults to/.:timeout- milliseconds. Defaults to 10 minutes.:max_output- bytes of output to keep. Defaults to 4096.