porcelain v2.0.3 Porcelain.Process
Module for working with external processes launched with Porcelain.spawn/3
or Porcelain.spawn_shell/2
.
Summary
Functions
A struct representing a wrapped OS processes which provides the ability to exchange data with it
Check if the process is still running
Wait for the external process to terminate
Send iodata to the process’s stdin
Send an OS signal to the processes
Stops the process created with Porcelain.spawn/3
or
Porcelain.spawn_shell/2
. Also closes the underlying Erlang port
Types
Functions
A struct representing a wrapped OS processes which provides the ability to exchange data with it.
Specs
await(t, non_neg_integer | :infinity) ::
{:ok, Porcelain.Result.t} |
{:error, :noproc | :timeout}
Wait for the external process to terminate.
Returns Porcelain.Result
struct with the process’s exit status and output.
Automatically closes the underlying port in this case.
If timeout value is specified and the external process fails to terminate
before it runs out, atom :timeout
is returned.
Specs
send_input(t, iodata) :: iodata
Send iodata to the process’s stdin.
End of input is indicated by sending an empty message.
Caveat: when using Porcelain.Driver.Basic
, it is not possible to
indicate the end of input. You should stop the process explicitly using
stop/1
.
Send an OS signal to the processes.
No further communication with the process is possible after sending it a signal.
Specs
stop(t) :: true
Stops the process created with Porcelain.spawn/3
or
Porcelain.spawn_shell/2
. Also closes the underlying Erlang port.
May cause “broken pipe” message to be written to stderr.
Caveats
When using Porcelain.Driver.Basic
, Porcelain will merely close the Erlang port
connected to that process. This normally causes an external process to terminate provided that it
is listening on its stdin
. If not, the external process will continue running.
See http://erlang.org/pipermail/erlang-questions/2010-March/050227.html for some background info.
When using Porcelain.Driver.Goon
, a SIGTERM
signal will be sent to the external process. If it
doesn’t terminate after :goon_stop_timeout
seconds, a SIGKILL
will be sent to the process.