Skip to content

Commit

Permalink
Return :epipe if command is not running
Browse files Browse the repository at this point in the history
  • Loading branch information
akash-akya committed Sep 25, 2024
1 parent 9fcb065 commit b8a131f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/ex_cmd/process.ex
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,9 @@ defmodule ExCmd.Process do

def handle_call({:write_stdin, binary}, from, state) do
case State.pop_operation(state, :write_stdin) do
_ when state.status != :running ->
{:reply, {:error, :epipe}, state}

{:error, :operation_not_found} ->
case Operations.pending_input(state, from, binary) do
{:noreply, state} ->
Expand Down
4 changes: 2 additions & 2 deletions test/ex_cmd/process_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defmodule ExCmd.ProcessTest do
assert {:ok, 0} == Process.await_exit(s, 500)

# wait for the process to terminate
:timer.sleep(100)
:timer.sleep(200)
refute Elixir.Process.alive?(s.pid)
end

Expand All @@ -42,7 +42,7 @@ defmodule ExCmd.ProcessTest do
assert {:ok, 0} == Process.await_exit(s, 200)

# wait for the process to terminate
:timer.sleep(100)
:timer.sleep(200)
refute Elixir.Process.alive?(s.pid)
end

Expand Down

0 comments on commit b8a131f

Please sign in to comment.