Skip to content

Commit

Permalink
Fix rabbitmq-diagnostics remote_shell for 26.0 (#7441) (#7443)
Browse files Browse the repository at this point in the history
(cherry picked from commit 74ce1a4)

Co-authored-by: Loïc Hoguin <[email protected]>
  • Loading branch information
mergify[bot] and lhoguin authored Feb 27, 2023
1 parent 2b5d084 commit c83f3e1
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c83f3e1

Please sign in to comment.