Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Erlang

Idiom #87 Stop program

Exit immediately.
If some extra cleanup work is executed by the program runtime (not by the OS itself), describe it.

erlang:halt(0).

0_ means normal termination. Any other integer will result in that value being the exit status of the program.
A string will crash the vm and generate a crash report with that as the slogan.
The atom abort will cause the runtime system to abort, if that's allowed

For integer Status the Erlang runtime system closes all ports and allows async threads to finish their operations before exiting. To exit without such flushing use you can use
erlang:halt( Status, [{flush, false}]).
return 0;

Only works in main(), actually.

New implementation...