Skip to content

Commit

Permalink
Merge branch 'lukas/kernel/fix-group-history-startup-deadlock/OTP-192…
Browse files Browse the repository at this point in the history
…05' into maint

* lukas/kernel/fix-group-history-startup-deadlock/OTP-19205:
  kernel: Don't load group history when in noshell mode
  • Loading branch information
garazdawi committed Sep 2, 2024
2 parents 9848e8f + ec91a1f commit 8641020
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
11 changes: 10 additions & 1 deletion lib/kernel/src/group.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ server(Ancestors, Drv, Shell, Options) ->
process_flag(trap_exit, true),
_ = [put('$ancestors', Ancestors) || Shell =/= {}],
edlin:init(),
put(line_buffer, proplists:get_value(line_buffer, Options, group_history:load())),
put(read_mode, list),
put(user_drv, Drv),

Expand All @@ -66,6 +65,16 @@ server(Ancestors, Drv, Shell, Options) ->
%% expand_below can be set by user_drv and ssh_cli
put(expand_below, proplists:get_value(expand_below, Options, true)),

DefaultGroupHistory =
case not get(echo) of
true ->
[];
false ->
group_history:load()
end,

put(line_buffer, proplists:get_value(line_buffer, Options, DefaultGroupHistory)),

server_loop(Drv, start_shell(Shell), []).

whereis_shell() ->
Expand Down
16 changes: 14 additions & 2 deletions lib/kernel/test/init_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

-export([get_arguments/1, get_argument/1, boot_var/1, restart/1,
many_restarts/0, many_restarts/1, restart_with_mode/1,
get_plain_arguments/1,
get_plain_arguments/1, init_group_history_deadlock/1,
reboot/1, stop_status/1, stop/1, get_status/1, script_id/1,
dot_erlang/1, unknown_module/1, dash_S/1, dash_extra/1,
dash_run/1, dash_s/1,
Expand All @@ -51,7 +51,8 @@ suite() ->
all() ->
[get_arguments, get_argument, boot_var,
many_restarts, restart_with_mode,
get_plain_arguments, restart, stop_status, get_status, script_id,
get_plain_arguments, init_group_history_deadlock,
restart, stop_status, get_status, script_id,
dot_erlang, unknown_module, {group, boot},
dash_S, dash_extra, dash_run, dash_s].

Expand Down Expand Up @@ -228,6 +229,17 @@ get_plain_arguments(Config) when is_list(Config) ->
ok.


init_group_history_deadlock(_Config) ->
Output = os:cmd(ct:get_progname() ++ " -noshell -eval \"logger:warning(\\\"testing\\\")\" "
"-inets services crashme -eval \"application:start(inets, permanent).\" "),

io:format("Got output: ~ts~n",[Output]),

case string:find(Output, "removed_failing_handler") of
nomatch -> ok;
_ -> ct:fail("Found unexpected printout in log")
end.

%% ------------------------------------------------
%% Use -boot_var flag to set $TEST_VAR in boot script.
%% ------------------------------------------------
Expand Down

0 comments on commit 8641020

Please sign in to comment.