File 0383-erts-Fix-handling-of-io-messages-in-init.patch of Package erlang
From 53b69daa284fba9f01506dc30018569113c7b004 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Tue, 16 Feb 2021 17:02:45 +0100
Subject: [PATCH 1/2] erts: Fix handling of io messages in init
Fixes a bug introduced in 95dcdb7754
---
erts/preloaded/src/init.erl | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/erts/preloaded/src/init.erl b/erts/preloaded/src/init.erl
index 099b80b249..ea2b7db2d5 100644
--- a/erts/preloaded/src/init.erl
+++ b/erts/preloaded/src/init.erl
@@ -485,17 +485,28 @@ do_handle_msg(Msg,State) ->
end;
{From, {ensure_loaded, _}} ->
From ! {init, not_allowed};
- X ->
- %% Only call the logger module if the logger_server is running.
- %% If it is not running, then we don't know that the logger
- %% module can be loaded.
- case whereis(logger_server) =/= undefined of
- true -> logger:info("init got unexpected: ~p", [X],
- #{ error_logger=>#{tag=>info_msg}});
- false -> erlang:display_string("init got unexpected: "),
- erlang:display(X)
+ X ->
+ case whereis(user) of
+ %% io_requests may end up here from various processes that have
+ %% init as their group_leader. Most notably all application_master
+ %% processes have init as their gl, though they will short-circuit
+ %% to `user` if possible.
+ User when element(1, X) =:= io_request,
+ User =/= undefined ->
+ User ! X;
+ _ ->
+ %% Only call the logger module if the logger_server is running.
+ %% If it is not running, then we don't know that the logger
+ %% module can be loaded.
+ case whereis(logger) =/= undefined of
+ true -> logger:info("init got unexpected: ~p", [X],
+ #{ error_logger=>#{tag=>info_msg}});
+ false ->
+ erlang:display_string("init got unexpected: "),
+ erlang:display(X)
+ end
end
- end.
+ end.
%%% -------------------------------------------------
%%% A new release has been installed and made
--
2.26.2