Skip to content

Commit c31eabd

Browse files
committed
Merge branch 'dgud/runtime_tools/observer-port-crash/GH-7735/OTP-18868' into maint
* dgud/runtime_tools/observer-port-crash/GH-7735/OTP-18868: Fix port crash
2 parents a2d31b7 + abafcba commit c31eabd

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

lib/runtime_tools/src/observer_backend.erl

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,21 @@ get_mnesia_loop(Parent, {Match, Cont}) ->
169169

170170
get_port_list() ->
171171
ExtraItems = [monitors,monitored_by,parallelism,locking,queue_size,memory],
172-
[begin
173-
[{port_id,P}|erlang:port_info(P)] ++
174-
port_info(P,ExtraItems) ++
175-
inet_port_extra(erlang:port_info(P, name), P)
176-
end || P <- erlang:ports()].
172+
PortInfo =
173+
fun(P, Acc) ->
174+
case erlang:port_info(P) of
175+
undefined ->
176+
Acc;
177+
Info ->
178+
[
179+
[{port_id,P}|Info] ++
180+
port_info(P,ExtraItems) ++
181+
inet_port_extra(erlang:port_info(P, name), P)
182+
| Acc ]
183+
end
184+
end,
185+
PIs = lists:foldl(PortInfo, [], erlang:ports()),
186+
lists:reverse(PIs).
177187

178188
port_info(P,[Item|Items]) ->
179189
case erlang:port_info(P,Item) of

0 commit comments

Comments
 (0)