Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
akash-akya committed Sep 21, 2024
1 parent 1e12072 commit 147020f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/ex_cmd/process.ex
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ defmodule ExCmd.Process do
# sleep command does not watch for stdin or stdout, so closing the
# pipe does not terminate the sleep command.
iex> {:ok, p} = Process.start_link(~w(sleep 100000000)) # sleep indefinitely
iex> Process.await_exit(p, 500) # ensure `await_exit` finish within `500ms`. By default it waits for 5s
iex> Process.await_exit(p, 1000) # ensure `await_exit` finish within `1000ms`. By default it waits for 5s
{:error, :killed} # command exit due to SIGTERM
```
Expand Down
14 changes: 7 additions & 7 deletions test/ex_cmd/process_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ defmodule ExCmd.ProcessTest do

test "if await_exit kills the program" do
{:ok, s} = Process.start_link(~w(sleep 10000))
assert_killed(Process.await_exit(s, 500))
assert_killed(Process.await_exit(s, 1000))
end

test "if external program terminates on process exit" do
Expand Down Expand Up @@ -253,14 +253,14 @@ defmodule ExCmd.ProcessTest do

@tag skip: Application.compile_env!(:ex_cmd, :current_os) == :windows
test "await_exit with timeout" do
{:ok, s} = Process.start_link([fixture("ignore_sigterm.sh")])
{:ok, s} = Process.start_link([fixture("ignore_sigterm.sh")], log: :stderr)
{:ok, os_pid} = Process.os_pid(s)
assert os_process_alive?(os_pid)

assert {:ok, "ignored signals\n" <> _} = Process.read(s)

# attempt to kill the process after 200ms
assert_killed(Process.await_exit(s, 200))
# attempt to kill the process after 1000ms
assert_killed(Process.await_exit(s, 1000))

refute os_process_alive?(os_pid)
refute Elixir.Process.alive?(s.pid)
Expand Down Expand Up @@ -345,7 +345,7 @@ defmodule ExCmd.ProcessTest do
test "if ex_cmd process is *NOT* terminated on owner exit, if any pipe owner is alive" do

Check failure on line 345 in test/ex_cmd/process_test.exs

View workflow job for this annotation

GitHub Actions / Linux OTP 24.x / Elixir 1.14.x

test process termination if ex_cmd process is *NOT* terminated on owner exit, if any pipe owner is alive (ExCmd.ProcessTest)

Check failure on line 345 in test/ex_cmd/process_test.exs

View workflow job for this annotation

GitHub Actions / Linux OTP 25.x / Elixir 1.15.x

test process termination if ex_cmd process is *NOT* terminated on owner exit, if any pipe owner is alive (ExCmd.ProcessTest)

Check failure on line 345 in test/ex_cmd/process_test.exs

View workflow job for this annotation

GitHub Actions / Linux OTP 26.x / Elixir 1.16.x

test process termination if ex_cmd process is *NOT* terminated on owner exit, if any pipe owner is alive (ExCmd.ProcessTest)

Check failure on line 345 in test/ex_cmd/process_test.exs

View workflow job for this annotation

GitHub Actions / Linux OTP 27.x / Elixir 1.17.x

test process termination if ex_cmd process is *NOT* terminated on owner exit, if any pipe owner is alive (ExCmd.ProcessTest)
parent = self()

{:ok, s} = Process.start_link(~w(cat), log: :stderr)
{:ok, s} = Process.start_link(~w(cat))

io_proc =
spawn_link(fn ->
Expand All @@ -361,7 +361,7 @@ defmodule ExCmd.ProcessTest do
end

# external process will be killed with SIGTERM (143)
assert_killed(Process.await_exit(s, 200))
assert_killed(Process.await_exit(s, 1000))

# wait for messages to propagate, if there are any
:timer.sleep(100)
Expand Down Expand Up @@ -407,7 +407,7 @@ defmodule ExCmd.ProcessTest do
:owner_changed -> :ok
end

assert_killed(Process.await_exit(s, 200))
assert_killed(Process.await_exit(s, 1000))

refute os_process_alive?(os_pid)
assert {:error, :epipe} == Task.await(task)
Expand Down

0 comments on commit 147020f

Please sign in to comment.