Hermanverschooten

Hermanverschooten

Generally when I want to quit an iex session I use the double control-c dance.
For unknown reasons this refused to work earlier today but I am not getting into that.
Because of it though I tried System.halt/1 to exit the session and that worked.

Is there a difference between the 2 methods?

Else I could add something like this to my .iex.exs

defmodule IexExtra do
  def exit, do: System.halt()
end
import IexExtra

Then I can end my sessions with a plain and simple exit

Showing Posts 1 to 10

slouchpie

slouchpie

I often use control-\

Hermanverschooten

Hermanverschooten OP

That combination seems to be bound to tmux, it jumps back to the last pane.

DidactMacros

DidactMacros

Maybe the normal close (ctlr double c) uses stop instead, which is meant to be less aggressive than System.halt.

There may have been something preventing the sequential shutdown of the runtime?

Hermanverschooten

Hermanverschooten OP

Definitely not System.stop, when I do that I see a lot of errors/warnings I do not see with the ctrl-c nor System.halt

sodapopcan

sodapopcan

WHOA! I had no idea that worked.

03juan

03juan

Here’s another tip courtesy of the System module.

You know “that” error…?

** (RuntimeError) could not compile application: my_app.

You must restart your server after changing the following files:

  • config/dev.exs

    (phoenix 1.7.12) lib/phoenix/code_reloader/server.ex:236: Phoenix.CodeReloader.Server.mix_compile_unless_stale_config/4

Just do as it says… :lol:

iex> System.restart()

It’ll recompile and reload everything for you.

acangiano

acangiano

The first CTRL-C gets you into the break menu which gives you a few diagnostic options. When you then press q or a and ENTER, or simply another CTRL-C you are effectively doing a System.halt(0) call.

CTRL-\ bypasses the break menu altogether and quits.

System.stop(0) is more graceful than System.halt(0). System.stop(0) signals :sigstop to the Erlang VM. It’s the same as calling :init.stop(0). From the documentation:

All applications are taken down smoothly, all code is unloaded, and all ports are closed before the system terminates by calling halt(Status).

System.halt(0) signals a :sigquit to the VM, which is equal to calling :erlang.halt(0). It abruptly shuts down everything (no apps are gracefully stopped or ports properly closed.)

You’ll notice that System.stop(0) takes a moment to shut down and returns an :ok atom if successful. System.halt(0) is essentially immediate.

arcanemachine

arcanemachine

I always assumed that System.halt was more aggressive in that sense. I mean, System.stop takes longer, so it must be exiting more gracefully!

That being said, I always exit by double-pressing Ctrl + C, and I’ve never had any issues with ports being left open, or any bad side effects like that.

Would love to get this cleared up, though, simply for the sake of “best practices”.

acangiano

acangiano

There are scenarios where CTRL-C twice could take down daemons running on a remote node. Not much harm if you are just messing around locally. However, if we are talking best practices, you’d probably want CTRL-G to bring up the User switch command menu, followed by q. Try h to see the options available.

slouchpie

slouchpie

I use zellij

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews