ex_cmd v0.3.0 ExCmd.Process View Source

Server to interact with external process

ExCmd.stream! should be preferred over this. Use this only if you need more control over the life-cycle of IO streams and OS process.

Link to this section Summary

Functions

Waits for the program to terminate.

Returns a specification to start this module under a supervisor.

Closes input stream. Which signal EOF to the program

Returns os pid of the command

Return bytes written by the program to output stream.

Starts a process using cmd_with_args and with options opts

Returns status of the process. It will be either of :started, {:done, exit_status}

Kills the program

Writes iodata data to programs input streams

Link to this section Functions

Link to this function

await_exit(server, timeout \\ :infinity)

View Source

Waits for the program to terminate.

If the program terminates before timeout, it returns {:ok, exit_status} else returns :timeout

Returns a specification to start this module under a supervisor.

See Supervisor in Elixir v1.6+.

Closes input stream. Which signal EOF to the program

Returns os pid of the command

Returns port_info

Link to this function

read(server, timeout \\ :infinity)

View Source
read(pid(), non_neg_integer() | :infinity) ::
  {:ok, iodata()} | :eof | {:error, String.t()} | :closed

Return bytes written by the program to output stream.

This blocks until the programs write and flush the output

Link to this function

start_link(list, opts \\ [])

View Source

Starts a process using cmd_with_args and with options opts

cmd_with_args must be a list containing command with arguments. example: ["cat", "file.txt"].

Options

  • cd - the directory to run the command in
  • env - an enumerable of tuples containing environment key-value. These can be accessed in the external program
  • log - When set to true odu logs and command stderr output are logged. Defaults to false

Returns status of the process. It will be either of :started, {:done, exit_status}

Kills the program

Link to this function

write(server, data, timeout \\ :infinity)

View Source
write(pid(), iodata(), non_neg_integer() | :infinity) ::
  :ok | {:error, String.t()} | :closed

Writes iodata data to programs input streams

This blocks when the pipe is full