summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSverker Eriksson <sverker@erlang.org>2023-04-21 19:27:01 +0200
committerSverker Eriksson <sverker@erlang.org>2023-04-21 19:51:47 +0200
commit2b2034cd070afccfaccf4ff8b3a9050eb090290e (patch)
treecf3fb9afd638fd3bb152cbc57f3093f6f52da5b9
parent5400ccf243a31d664153a4b9ceb9de3edfce1e0e (diff)
downloaderlang-2b2034cd070afccfaccf4ff8b3a9050eb090290e.tar.gz
os_mon: Fix failing port_close
Use asynchtonous close message to not fail on already closed port.
-rw-r--r--lib/os_mon/src/cpu_sup.erl4
-rw-r--r--lib/os_mon/src/memsup.erl2
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/os_mon/src/cpu_sup.erl b/lib/os_mon/src/cpu_sup.erl
index be917021e7..adf1f45265 100644
--- a/lib/os_mon/src/cpu_sup.erl
+++ b/lib/os_mon/src/cpu_sup.erl
@@ -613,8 +613,8 @@ port_server_loop(Port, Timeout) ->
% Close port and this server
{Pid, ?quit} ->
- port_command(Port, ?quit),
- port_close(Port),
+ Port ! {self(), {command, ?quit}},
+ Port ! {self(), close},
Pid ! {self(), {data, quit}},
ok;
diff --git a/lib/os_mon/src/memsup.erl b/lib/os_mon/src/memsup.erl
index 1c93bfbae4..c467adc2e5 100644
--- a/lib/os_mon/src/memsup.erl
+++ b/lib/os_mon/src/memsup.erl
@@ -653,7 +653,7 @@ start_portprogram() ->
port_shutdown(Port) ->
Port ! {self(), {command, [?EXIT]}},
- port_close(Port).
+ Port ! {self(), close}.
%% The connected process loops are a bit awkward (several different
%% functions doing almost the same thing) as