Skip to content

Commit 9181630

Browse files
committed
Wait for processes to exit when stopping
1 parent 9e6f674 commit 9181630

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/observer/src/etop.erl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ stop() ->
139139
Pid when is_pid(Pid) ->
140140
Result = etop_server ! stop,
141141
stop_etop_input_server(),
142+
MonRef = monitor(process, Pid),
143+
receive {'DOWN', MonRef, process, Pid, _} -> ok end,
144+
demonitor(MonRef),
142145
Result
143146
end.
144147

@@ -328,7 +331,13 @@ stop(Reader, Opts) ->
328331
etop_tr:stop_tracer(Opts),
329332
%% Stop reader process so it doesn't crash on deleted accumulator table
330333
%% when our process dies.
331-
exit(Pid, stop);
334+
case is_process_alive(Pid) of
335+
true ->
336+
exit(Pid, stop),
337+
receive {'EXIT', Pid, stop} -> ok
338+
end;
339+
false -> ok
340+
end;
332341
_ ->
333342
ok
334343
end,

0 commit comments

Comments
 (0)