diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ct_helper.erl | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ct_helper.erl b/src/ct_helper.erl index 29d419f..73dd96a 100644 --- a/src/ct_helper.erl +++ b/src/ct_helper.erl @@ -25,6 +25,8 @@ -export([get_remote_pid_tcp/1]). -export([get_remote_pid_tls/1]). -export([ignore/3]). +-export([is_process_down/1]). +-export([is_process_down/2]). -export([make_certs/0]). -export([make_certs_in_ets/0]). -export([name/0]). @@ -148,6 +150,23 @@ get_remote_pid_tls(Socket) -> ignore(M, F, A) -> ct_helper_error_h:ignore(M, F, A). +%% @doco Similar to erlang:is_process_alive/1 except +%% it uses monitors and waits up to a timeout. +%% +%% The return value is also the opposite of alive (down). + +is_process_down(Pid) -> + is_process_down(Pid, 1000). + +is_process_down(Pid, Timeout) -> + MRef = monitor(process, Pid), + receive + {'DOWN', MRef, process, Pid, _} -> + true + after Timeout -> + false + end. + %% @doc Create a set of certificates. -spec make_certs() |