From 8b501f5fe674e8db217c7f72c374ca60494658bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chmielowski?= Date: Wed, 24 Apr 2019 13:46:09 +0200 Subject: [PATCH] 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. --- src/gen_mod.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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