Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos #12

Merged
merged 1 commit into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/exile.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ defmodule Exile do

* `exit_timeout` - Duration to wait for external program to exit after completion before raising an error. Defaults to `:infinity`

* `max_chunk_size` - Maximum size of each iodata chunk emitted by stream. Chunk size will be variable depending on the amount of data availble at that time. Defaults to 65535
* `max_chunk_size` - Maximum size of each iodata chunk emitted by stream. Chunk size will be variable depending on the amount of data available at that time. Defaults to 65535

* `use_stderr` - When set to true, stream will contain stderr output along with stdout output. Element of the stream will be of the form `{:stdout, iodata}` or `{:stderr, iodata}` to differentiate different streams. Defaults to false. See example below

Expand Down
10 changes: 5 additions & 5 deletions lib/exile/process.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ defmodule Exile.Process do

* it is demand driven. User explicitly has to `read` the command output, and the progress of the external command is controlled using OS pipes. Exile never load more output than we can consume, so we should never experience memory issues
* it can close stdin while consuming output
* tries to handle zombie process by attempting to cleanup external process. Note that there is no middleware involved with exile so it is still possbile to endup with zombie process.
* tries to handle zombie process by attempting to cleanup external process. Note that there is no middleware involved with exile so it is still possible to endup with zombie process.
* selectively consume stdout and stderr streams

Internally Exile uses non-blocking asynchronous system calls to interact with the external process. It does not use port's message based communication, instead uses raw stdio and NIF. Uses asynchronous system calls for IO. Most of the system calls are non-blocking, so it should not block the beam schedulers. Make use of dirty-schedulers for IO
Expand Down Expand Up @@ -96,7 +96,7 @@ defmodule Exile.Process do
@doc """
Returns bytes from executed command's stdout stream with maximum size `max_size`.

Blocks if no bytes are written to stdout stream yet. And returns as soon as bytes are availble
Blocks if no bytes are written to stdout stream yet. And returns as soon as bytes are available
"""
@spec read(process, pos_integer()) :: {:ok, iodata} | :eof | {:error, any()}
def read(process, max_size \\ @default_buffer_size)
Expand All @@ -107,17 +107,17 @@ defmodule Exile.Process do
@doc """
Returns bytes from executed command's stderr stream with maximum size `max_size`.

Blocks if no bytes are written to stdout stream yet. And returns as soon as bytes are availble
Blocks if no bytes are written to stdout stream yet. And returns as soon as bytes are available
"""
@spec read_stderr(process, pos_integer()) :: {:ok, iodata} | :eof | {:error, any()}
def read_stderr(process, size \\ @default_buffer_size) when is_integer(size) and size > 0 do
GenServer.call(process, {:read_stderr, size}, :infinity)
end

@doc """
Returns bytes from either stdout or stderr stream with maximum size `max_size` whichever is availble.
Returns bytes from either stdout or stderr stream with maximum size `max_size` whichever is available.

Blocks if no bytes are written to stdout/stderr stream yet. And returns as soon as bytes are availble
Blocks if no bytes are written to stdout/stderr stream yet. And returns as soon as bytes are available
"""
@spec read_any(process, pos_integer()) ::
{:ok, {:stdout, iodata}} | {:ok, {:stderr, iodata}} | :eof | {:error, any()}
Expand Down
2 changes: 1 addition & 1 deletion lib/exile/stream.ex
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ defmodule Exile.Stream do

after_fun = fn exit_type ->
try do
# always close stdin before stoping to give the command chance to exit properly
# always close stdin before stopping to give the command chance to exit properly
Process.close_stdin(process)
result = Process.await_exit(process, stream_opts.exit_timeout)

Expand Down