diff --git a/apps/emqx/src/emqx_sys_mon.erl b/apps/emqx/src/emqx_sys_mon.erl index 1f8f04d97..1df9ec604 100644 --- a/apps/emqx/src/emqx_sys_mon.erl +++ b/apps/emqx/src/emqx_sys_mon.erl @@ -202,7 +202,12 @@ get_proc_lib_initial_call(Pid) -> end. portinfo(Port) -> - [{port, Port} | erlang:port_info(Port)]. + PortInfo = + case is_port(Port) andalso erlang:port_info(Port) of + L when is_list(L) -> L; + _ -> [] + end, + [{port, Port} | PortInfo]. safe_publish(Event, WarnMsg) -> Topic = emqx_topic:systop(lists:concat(['sysmon/', Event])), diff --git a/apps/emqx/test/emqx_sys_mon_SUITE.erl b/apps/emqx/test/emqx_sys_mon_SUITE.erl index 8e4bd65db..31acd885f 100644 --- a/apps/emqx/test/emqx_sys_mon_SUITE.erl +++ b/apps/emqx/test/emqx_sys_mon_SUITE.erl @@ -35,6 +35,11 @@ {self(), busy_port, fmt("busy_port warning: suspid = ~p, port = ~p", [self(), ?FAKE_PORT]), ?FAKE_PORT}, + %% for the case when the port is missing, for some + %% reason. + {self(), busy_port, + fmt("busy_port warning: suspid = ~p, port = ~p", + [self(), []]), []}, {self(), busy_dist_port, fmt("busy_dist_port warning: suspid = ~p, port = ~p", [self(), ?FAKE_PORT]), ?FAKE_PORT},