Program termination: Difference between revisions

Content added Content deleted
m (Regularize non-standard header markup)
(Add Factor)
Line 561: Line 561:
if condition then
if condition then
Environment.Exit 1</lang>
Environment.Exit 1</lang>

=={{header|Factor}}==
<lang factor>USING: kernel system ;

t [ 0 exit ] when</lang>
When the <code>exit</code> word is called, first it runs the shutdown hooks, and then exits the Factor VM, passing along an exit code to the operating system. If an error occurs while running the shutdown hooks, the error is ignored and the exit code <code>255</code> is passed along.

You can add your own shutdown hooks like so:

<lang factor>USING: init io ;

[ "Exiting Factor..." print ] "message" add-shutdown-hook</lang>

They are name/quotation pairs that are added to the associative mapping at the <code>shutdown-hooks</code> symbol in the <code>init</code> vocabulary.


=={{header|Forth}}==
=={{header|Forth}}==