diff --git a/lib/observer/src/etop.erl b/lib/observer/src/etop.erl index e4ffe5d9c459..7c6b5c8e2947 100644 --- a/lib/observer/src/etop.erl +++ b/lib/observer/src/etop.erl @@ -137,9 +137,11 @@ stop() -> case whereis(etop_server) of undefined -> not_started; Pid when is_pid(Pid) -> - Result = etop_server ! stop, + MonRef = monitor(process, Pid), + Pid ! stop, stop_etop_input_server(), - Result + receive {'DOWN', MonRef, process, Pid, _} -> ok end, + stop end. -doc """ @@ -328,7 +330,13 @@ stop(Reader, Opts) -> etop_tr:stop_tracer(Opts), %% Stop reader process so it doesn't crash on deleted accumulator table %% when our process dies. - exit(Pid, stop); + case is_process_alive(Pid) of + true -> + MonRef = monitor(process, Pid), + exit(Pid, stop), + receive {'DOWN', MonRef, process, Pid, _} -> ok end; + false -> ok + end; _ -> ok end, diff --git a/lib/observer/test/etop_SUITE.erl b/lib/observer/test/etop_SUITE.erl index 62d668810c39..ef50db12b975 100644 --- a/lib/observer/test/etop_SUITE.erl +++ b/lib/observer/test/etop_SUITE.erl @@ -232,8 +232,7 @@ text_in_terminal(Config) when is_list(Config) -> Node = proplists:get_value(node, Config), Term = proplists:get_value(term, Config), ExpectedLineCount = 10 + proplists:get_value(lines, Config, 10) + 2, - - EtopStartCmd = "spawn_link(etop, start, [[{node,"++atom_to_list(Node)++"},{output,text},{interval,1}]]).", + EtopStartCmd = io_lib:format("spawn_link(etop, start, [[{node,~w},{output,text},{interval,1}]]).", [Node]), shell_test_lib:send_tty(Term, EtopStartCmd), shell_test_lib:send_tty(Term, "Enter"), @@ -406,8 +405,8 @@ verify_dup_line(Char, Line) -> true = string:equal(ExpectedLine, Line). verify_node_and_time_line(Node, NodeAndTimeLine) -> - NodeString = atom_to_binary(Node), [NodeString | SplitLine] = string:split(string:trim(NodeAndTimeLine), " ", all), + Node = binary_to_atom(string:trim(NodeString, both, "'")), TimeLine = lists:last(SplitLine), [Hour, Minute, Second] = string:split(TimeLine, ":", all),