diff options
author | Håkan Mattsson <[email protected]> | 2010-04-01 13:09:35 +0200 |
---|---|---|
committer | Håkan Mattsson <[email protected]> | 2010-04-19 13:17:33 +0200 |
commit | 2f304e221f790af9b0bf15d9ea8f8f447159351e (patch) | |
tree | dbfa42e77e516021a814e79344d5f88bc5b4c9e2 /lib/reltool/src/reltool.erl | |
parent | 21db0d0e7e7112d7c257ed19fc8e3c0a90d4698b (diff) | |
download | otp-2f304e221f790af9b0bf15d9ea8f8f447159351e.tar.gz otp-2f304e221f790af9b0bf15d9ea8f8f447159351e.tar.bz2 otp-2f304e221f790af9b0bf15d9ea8f8f447159351e.zip |
Ensure that {error, Reason} is returned even when server dies
Diffstat (limited to 'lib/reltool/src/reltool.erl')
-rw-r--r-- | lib/reltool/src/reltool.erl | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/reltool/src/reltool.erl b/lib/reltool/src/reltool.erl index 351a3d59cf..9dd0a24f46 100644 --- a/lib/reltool/src/reltool.erl +++ b/lib/reltool/src/reltool.erl @@ -99,16 +99,19 @@ stop(Pid) when is_pid(Pid) -> -spec eval_server(server(), boolean(), fun((server_pid()) -> term())) -> {ok, server_pid()} | {error, reason()}. eval_server(Pid, DisplayWarnings, Fun) - when is_pid(Pid), is_boolean(DisplayWarnings) -> + when is_pid(Pid) -> Fun(Pid); eval_server(Options, DisplayWarnings, Fun) - when is_list(Options), is_boolean(DisplayWarnings), is_function(Fun, 1) -> - case start_server(Options) of - {ok, Pid} -> - apply_fun(Pid, DisplayWarnings, Fun); - {error, Reason} -> - {error, Reason} - end. + when is_list(Options) -> + TrapExit = process_flag(trap_exit, true), + Res = case start_server(Options) of + {ok, Pid} -> + apply_fun(Pid, DisplayWarnings, Fun); + {error, Reason} -> + {error, Reason} + end, + process_flag(trap_exit, TrapExit), + Res. apply_fun(Pid, false, Fun) -> Res = Fun(Pid), |