Logo

Programming-Idioms

History of Idiom 87 > diff from v9 to v10

Edit summary for version 10 by :

Version 9

2015-10-29, 13:00:07

Version 10

2015-10-29, 14:05:16

Idiom #87 Stop program

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

Idiom #87 Stop program

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

Code
erlang:halt(0).
Code
erlang:halt(0).
Comments bubble
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}]).
Comments bubble
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}]).
Doc URL
http://erldocs.com/current/erts/erlang.html?i=0&search=halt#halt/0
Doc URL
http://erldocs.com/current/erts/erlang.html?i=0&search=halt#halt/0
Demo URL
http://tryerl.seriyps.ru/#id=23f3
Demo URL
http://tryerl.seriyps.ru/#id=23f3
Code
std::process::exit(0);
Code
std::process::exit(0);
Comments bubble
No destructors on the current stack or any other thread's stack will be run.
Comments bubble
No destructors on the current stack or any other thread's stack will be run.
Doc URL
http://doc.rust-lang.org/std/process/fn.exit.html
Doc URL
http://doc.rust-lang.org/std/process/fn.exit.html
Demo URL
https://play.rust-lang.org/?code=fn%20main()%20%7B%0A%20%20%20%20std%3A%3Aprocess%3A%3Aexit(1)%3B%0A%20%20%20%20println!(%2242%22)%3B%0A%7D&version=stable
Demo URL
https://play.rust-lang.org/?code=fn%20main()%20%7B%0A%20%20%20%20std%3A%3Aprocess%3A%3Aexit(1)%3B%0A%20%20%20%20println!(%2242%22)%3B%0A%7D&version=stable
Code
System.exit(0);
Code
System.exit(0);
Comments bubble
This stops the whole JVM.
Status code 0 means "normal termination".
Comments bubble
This stops the whole JVM.
Status code 0 means "normal termination".
Doc URL
https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#exit-int-
Doc URL
https://docs.oracle.com/javase/8/docs/api/java/lang/System.html#exit-int-