diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/remote_shell_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/remote_shell_command.ex index 1d4726bc61a..231b09c3ff1 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/remote_shell_command.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/remote_shell_command.ex @@ -6,19 +6,27 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.RemoteShellCommand do @behaviour RabbitMQ.CLI.CommandBehaviour + @dialyzer :no_missing_calls use RabbitMQ.CLI.Core.MergesNoDefaults use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments def run([], %{node: node_name}) do - _ = Supervisor.terminate_child(:kernel_sup, :user) - Process.flag(:trap_exit, true) - user_drv = :user_drv.start(['tty_sl -c -e', {node_name, :shell, :start, []}]) - Process.link(user_drv) - - receive do - {'EXIT', _user_drv, _} -> - {:ok, "Disconnected from #{node_name}."} + _ = :c.l(:shell) + + if :erlang.function_exported(:shell, :start_interactive, 1) do + :shell.start_interactive({node_name, :shell, :start, []}) + :timer.sleep(:infinity) + else + _ = Supervisor.terminate_child(:kernel_sup, :user) + Process.flag(:trap_exit, true) + user_drv = :user_drv.start(['tty_sl -c -e', {node_name, :shell, :start, []}]) + Process.link(user_drv) + + receive do + {'EXIT', _user_drv, _} -> + {:ok, "Disconnected from #{node_name}."} + end end end