Exiting iex and stopping everything

I like to run iex -S mix phx.server as I develop.
When I stop, I hit Ctrl + C, but this doesn’t kill the beam process.

So I have to find the pid being used by beam, and run kill -15 on it. Actually, I have a tiny bash function for automating this, but you get the idea.
If I don’t keep doing this, the orphaned processes will quickly eat up all my memory.

Is there a better way to stop everything, rather than ctrl + c?

Try CTRL-\

1 Like

Ctrl + C twice should definitely kill the process and not orphan it, or Ctrl + C, a. What kind of system are you on?

2 Likes

Hmm same thing happens with Ctrl + \

I’m on Centos 8 (although I believe it was also happening to me on Centos 7)

Perhaps C-g q RET works better? There are plenty of ways to quit, not many of them are considered proper, and I haven’t understood for myself which to use when :smiley:

Could you please also tell which version of Elixir/Erlang you are using and perhaps from where you have installed them?

Ctrl + \ or System.stop/0 if you wanna stop the whole node even in a remote shell.

2 Likes

System.stop gave the same thing. As did Ctrl-g q
I didn’t know about those! :smiley:

I’m using asdf. I’m also doing this through ssh, if that matters, but changing local machines didn’t affect the problem.

I just noticed that I have Erlang/OTP 22.1, but in the same breath it says compiled with Erlang/OTP 20. Could that be an issue?

$ elixir --version
Erlang/OTP 22 [erts-10.5] [source] [64-bit] [smp:1:1] [ds:1:1:10] [async-threads:1] [hipe]

Elixir 1.9.3 (compiled with Erlang/OTP 20)

$ ps -A | grep beam
$ iex -S mix phx.server
... app starts, tests run, etc ...
Ctrl-c Ctrl-c
$ ps -A | grep beam
31250 ?        00:00:00 beam.smp
$ kill -15 31250
$ ps -A | grep beam
$

Is that not actually the beam process left running but epmd? Is your server actually still connectable after Ctrl+C’ing it twice?