Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

已关闭 适合新手
#15,975 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
75/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
erlang
领域
cli

调研方向

shell 在 lib/elixir/src/iex.erl 中启动:get_remsh 分支选择 MFA,start_mfa/2 为本地和远程 shell 都设置了 {on_eof, halt}。在 target 节点运行时,使用 printf '1\n' | iex --sname client --remsh target@host 复现,并确认 target 会退出。修复应只为远程分支传入不会停止的 on_eof,使远程节点继续运行,本地客户端以状态码 0 退出。请检查本地 iex 在输入结束时仍会停止。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Elixir
星标
26.7k
派生
3.7k
平均合并
8 小时 8 分钟
30 天内合并 PR
61

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

elixir-lang/elixir 的其他 Issue

查看 elixir-lang/elixir 的全部 Issue

相似的 Issue

更多 Elixir Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。