iex: q() shorthand for :init.stop()

21 views
Skip to first unread message

Benjamin Philip

unread,
Jan 16, 2026, 6:21:54 AM (3 days ago) Jan 16
to elixir-l...@googlegroups.com

Hi,

Currently the common way to exit iex is C-c C-c (Ctrl + c Ctrl + c). erl on the otherhand supports the q() helper, short for init:stop():

Erlang/OTP 28 [erts-16.0.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit:ns]

Eshell V16.0.2 (press Ctrl+G to abort, type help(). for help)
1> q().
ok
2> %

It would be great if we could introduce the same helper to iex.

– bp

José Valim

unread,
Jan 16, 2026, 6:53:04 AM (3 days ago) Jan 16
to elixir-l...@googlegroups.com
Thank you for the proposal. We didn't add this on purpose. Ctrl+C is the correct way to stop a remote shell. If you run `q()` on a remote node, it will stop the remote node, bringing production down. If that's what you want, type System.stop. :)


--
You received this message because you are subscribed to the Google Groups "elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-co...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/elixir-lang-core/CAMEXYWerue9T_inV-fmmxx4Kpi%3Dj-pFAC9yXujbu3SS7HXaNfA%40mail.gmail.com.

Benjamin Philip

unread,
Jan 16, 2026, 1:35:47 PM (3 days ago) Jan 16
to José Valim, elixir-l...@googlegroups.com

You’re right. I completely forgot about the case of connecting to a remote node.

I’m guessing the reason neither iex or erl doesn’t support just gracefully exiting the repl without killing any other processes because tty doesn’t support it? Then how does this work with Ctrl+C?

Additionally, Ctrl+D is typically the shortcut used to exit any shell (since it denotes EOF), not Ctrl+C. Most shells that support this probably inherited it from building on top of GNU readline or similar. I guess supporting this means patching edlin?

Nevertheless, I think it’s a small, but important, quality of life improvement to support a quit/exit function and Ctrl+D our shell, since it doesn’t break the muscle memory of people coming from (or constantly switching back and fro) other languages. It’s a standard that everything from mainstream repls like python, irb and node, to more academic languages like Haskell and Coq and even lisps (which have heavy remote repl usage) like clojure, common lisp and scheme adhere to.

Maybe it’s worth revisiting this after the necessary changes are made upstream?

– bp

Amos King

unread,
Jan 16, 2026, 3:45:06 PM (3 days ago) Jan 16
to elixir-l...@googlegroups.com, José Valim, elixir-l...@googlegroups.com

Greg Vaughn

unread,
Jan 18, 2026, 11:02:11 AM (19 hours ago) Jan 18
to elixir-l...@googlegroups.com
This was also brought up in 2014 :-)

https://github.com/elixir-lang/elixir/pull/1987

-Greg Vaughn

> On Jan 16, 2026, at 2:44 PM, Amos King <am...@binarynoggin.com> wrote:
>
> Saving José some time.
>
> This was brought up in 2018. This might be some good background information.
>
> https://github.com/elixir-lang/elixir/issues/7310
> To view this discussion visit https://groups.google.com/d/msgid/elixir-lang-core/1EEF9F30-A737-4757-8EFE-E68E3A771486%40binarynoggin.com.

Reply all
Reply to author
Forward
0 new messages