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 d8fe9bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/ex_cmd/process.ex
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ 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> {:ok, p} = Process.start_link(~w(sleep 100000000), log: :stderr) # sleep indefinitely
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
6 changes: 3 additions & 3 deletions test/ex_cmd/process_test.exs
Original file line number Diff line number Diff line change
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

0 comments on commit d8fe9bd

Please sign in to comment.