exexec v0.2.0 Exexec View Source
Execute and control OS processes from Elixir.
An idiomatic Elixir wrapper for Serge Aleynikov's excellent erlexec, Exexec provides an Elixir interface as well as some nice Elixir-y goodies on top.
Link to this section Summary
Functions
Send signal to pid.
Start an Exexec process to manage existing os_pid with options options.
Returns the OS pid for Exexec process pid.
Returns the Exexec pid for os_pid.
Run an external command with options.
Run an external command with options, linking to the current process.
Send data to the stdin of pid.
Change group ID of os_pid to gid.
Convert integer signal to atom, or return signal.
Start Exexec with options.
Start Exexec and link to calling process.
Start Exexec with options and link to calling process.
Interpret exit_code.
Stop pid.
Stop pid and wait for it to exit for timeout milliseconds.
Return a list of OS pids managed by Exexec.
Link to this section Types
command() View Source
command_option()
View Source
command_option() ::
{:monitor, boolean()}
| {:sync, boolean()}
| {:executable, Path.t()}
| {:cd, Path.t()}
| {:env, %{optional(String.t()) => String.t()}}
| {:kill_command, String.t()}
| {:kill_timeout, non_neg_integer()}
| {:kill_group, boolean()}
| {:group, String.t()}
| {:user, String.t()}
| {:success_exit_code, exit_code()}
| {:nice, -20..20}
| {:stdin, boolean() | :null | :close | Path.t()}
| {:stdout, :stderr | output_device_option()}
| {:stderr, :stdout | output_device_option()}
| {:pty, boolean()}
command_option() ::
{:monitor, boolean()}
| {:sync, boolean()}
| {:executable, Path.t()}
| {:cd, Path.t()}
| {:env, %{optional(String.t()) => String.t()}}
| {:kill_command, String.t()}
| {:kill_timeout, non_neg_integer()}
| {:kill_group, boolean()}
| {:group, String.t()}
| {:user, String.t()}
| {:success_exit_code, exit_code()}
| {:nice, -20..20}
| {:stdin, boolean() | :null | :close | Path.t()}
| {:stdout, :stderr | output_device_option()}
| {:stderr, :stdout | output_device_option()}
| {:pty, boolean()}
command_options()
View Source
command_options() :: [command_option()]
command_options() :: [command_option()]
exec_option() View Source
exec_options()
View Source
exec_options() :: [exec_option()]
exec_options() :: [exec_option()]
exit_code()
View Source
exit_code() :: non_neg_integer()
exit_code() :: non_neg_integer()
gid()
View Source
gid() :: non_neg_integer()
gid() :: non_neg_integer()
on_run()
View Source
on_run() ::
{:ok, pid(), os_pid()}
| {:ok, [{output_device(), [binary()]}]}
| {:error, any()}
on_run() ::
{:ok, pid(), os_pid()}
| {:ok, [{output_device(), [binary()]}]}
| {:error, any()}
os_pid()
View Source
os_pid() :: non_neg_integer()
os_pid() :: non_neg_integer()
output_device()
View Source
output_device() :: :stdout | :stderr
output_device() :: :stdout | :stderr
output_device_option()
View Source
output_device_option() ::
boolean()
| :null
| :close
| :print
| Path.t()
| {Path.t(), output_file_options()}
| pid()
| (output_device(), os_pid(), binary() -> any())
output_device_option() :: boolean() | :null | :close | :print | Path.t() | {Path.t(), output_file_options()} | pid() | (output_device(), os_pid(), binary() -> any())
output_file_option()
View Source
output_file_option() :: {:append, boolean()} | {:mode, non_neg_integer()}
output_file_option() :: {:append, boolean()} | {:mode, non_neg_integer()}
output_file_options()
View Source
output_file_options() :: [output_file_option()]
output_file_options() :: [output_file_option()]
signal()
View Source
signal() :: pos_integer()
signal() :: pos_integer()
Link to this section Functions
kill(pid, signal) View Source
Send signal to pid.
pid can be an Exexec pid, OS pid, or port.
manage(os_pid, options \\ []) View Source
Start an Exexec process to manage existing os_pid with options options.
os_pid can also be a port.
os_pid(pid) View Source
Returns the OS pid for Exexec process pid.
pid(os_pid) View Source
Returns the Exexec pid for os_pid.
run(command, options \\ [])
View Source
run(command(), command_options()) :: on_run()
run(command(), command_options()) :: on_run()
Run an external command with options.
run_link(command, options \\ [])
View Source
run_link(command(), command_options()) :: on_run()
run_link(command(), command_options()) :: on_run()
Run an external command with options, linking to the current process.
If the external process exits with code 0, the linked process will not exit.
send(pid, data) View Source
Send data to the stdin of pid.
pid can be an Exexec pid or an OS pid.
set_gid(os_pid, gid) View Source
Change group ID of os_pid to gid.
signal(signal) View Source
Convert integer signal to atom, or return signal.
start() View Source
Start Exexec.
start(options)
View Source
start(exec_options()) :: {:ok, pid()} | {:error, any()}
start(exec_options()) :: {:ok, pid()} | {:error, any()}
Start Exexec with options.
start_link() View Source
Start Exexec and link to calling process.
start_link(options)
View Source
start_link(exec_options()) :: {:ok, pid()} | {:error, any()}
start_link(exec_options()) :: {:ok, pid()} | {:error, any()}
Start Exexec with options and link to calling process.
status(exit_code) View Source
Interpret exit_code.
If the program exited by signal, returns {:signal, signal, core} where signal
is the atom or integer signal and core is whether a core file was generated.
stop(pid) View Source
Stop pid.
pid can be an Exexec pid, OS pid, or port.
The OS process is terminated gracefully. If :kill_command was specified,
that command is executed and a timer is started. If the process doesn't exit
immediately, then by default after 5 seconds SIGKILL will be sent to the process.
stop_and_wait(pid, timeout \\ 5000) View Source
Stop pid and wait for it to exit for timeout milliseconds.
See Exexec.stop/1.
which_children()
View Source
which_children() :: [os_pid()]
which_children() :: [os_pid()]
Return a list of OS pids managed by Exexec.