From: Paweł Chmielowski Date: Wed, 24 Apr 2019 11:46:09 +0000 (+0200) Subject: Catch potential exceptions in gen_mod:wait_for_process X-Git-Tag: 19.05~74 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8b501f5fe674e8db217c7f72c374ca60494658bc;p=ejabberd Catch potential exceptions in gen_mod:wait_for_process Seems that at ejabberd shutdown, process may terminate before that function is called, and in that case erlang:monitor throws exception. --- diff --git a/src/gen_mod.erl b/src/gen_mod.erl index cec3ddb24..4dc972fd9 100644 --- a/src/gen_mod.erl +++ b/src/gen_mod.erl @@ -364,8 +364,13 @@ stop_module_keep_config(Host, Module) -> end. wait_for_process(Process) -> - MonitorReference = erlang:monitor(process, Process), - wait_for_stop(Process, MonitorReference). + try erlang:monitor(process, Process) of + MonitorReference -> + wait_for_stop(Process, MonitorReference) + catch + _:_ -> + ok + end. wait_for_stop(Process, MonitorReference) -> receive