Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

iex --remsh halts the remote node at end of input

Chiusa Adatta ai principianti
#15,975 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
75/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
erlang
Ambito
cli

Direzione di ricerca

La shell viene avviata in lib/elixir/src/iex.erl: il caso get_remsh sceglie il MFA, e start_mfa/2 imposta {on_eof, halt} sia per le shell locali che per quelle remote. Riproduci con printf '1\n' | iex --sname client --remsh target@host mentre un nodo target è in esecuzione, e verifica che il nodo target termini. La correzione dovrebbe passare un on_eof non bloccante solo per il ramo remoto, così il nodo remoto continua a girare e il client locale termina con stato 0. Verifica che iex locale continui a terminare alla fine dell'input.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Elixir and Erlang/OTP versions

Elixir 1.20.1, 1.20.4 and main (b77fe287), on Erlang/OTP 28.5.0.2 and 29.1.1.

Operating system

NixOS (Linux)

Current behavior

iex --remsh halts the remote node when the local shell's input ends. In a terminal without line editing (TERM unset, dumb, or a TERM the host's terminfo lacks, for example xterm-kitty on a stock server), Ctrl+D on an empty line ends the input. The same happens when stdin is a pipe.

$ iex --sname target --cookie c
$ TERM=dumb iex --sname client --cookie c --remsh target@$(hostname -s)
iex(target@host)1> ^D

The target node exits with status 0. printf '1\n' | iex --sname client --cookie c --remsh target@host halts it the same way.

iex.erl passes {on_eof, halt} to IEx.Server for both local and remote shells (lib/elixir/src/iex.erl:78), and IEx.Server runs System.halt(0) on the remote node. With line editing, Ctrl+D only deletes forward, so the bug depends on the terminal. erl -remsh does not halt the remote node in the same setups.

Expected behavior

End of input in a remote shell ends the shell and leaves the remote node running, like erl -remsh. Halting on end of input makes sense for a local iex, where the shell owns the node.

A three-line change does it, passing stop_evaluator (IEx.Server's default) in the --remsh branch:

--- a/lib/elixir/src/iex.erl
+++ b/lib/elixir/src/iex.erl
@@ -53,7 +53,7 @@
   case get_remsh(Args) of
     nil ->
-      start_mfa(Args, {elixir, start_cli, []});
+      start_mfa(Args, {elixir, start_cli, []}, halt);
@@ -67,15 +67,15 @@
-      {remote, Remote, start_mfa(Args, {?MODULE, sync_remote, [Parent, Ref]})}
+      {remote, Remote, start_mfa(Args, {?MODULE, sync_remote, [Parent, Ref]}, stop_evaluator)}
   end.
@@
-start_mfa(Args, MFA) ->
-  Opts = [{dot_iex, get_dot_iex(Args)}, {on_eof, halt}],
+start_mfa(Args, MFA, OnEof) ->
+  Opts = [{dot_iex, get_dot_iex(Args)}, {on_eof, OnEof}],
   {?MODULE, start, [Opts, MFA]}.

With it, Ctrl+D and piped input end the client with status 0 and the remote node keeps running. Happy to open a PR.

Lingua principale
Elixir
Stelle
26.7k
Fork
3.7k
Merge medio
8h 7m
PR unite (30g)
60

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di elixir-lang/elixir

Tutte le issue di elixir-lang/elixir

Issue simili

Altre issue su Elixir

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.