Program termination: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
|||
Line 127: | Line 127: | ||
end f</lang> |
end f</lang> |
||
Memory is automatically managed and reclaimed by AppleScript. |
Memory is automatically managed and reclaimed by AppleScript. |
||
=={{header|ARM Assembly}}== |
=={{header|ARM Assembly}}== |
||
{{works with|as|Raspberry Pi}} |
{{works with|as|Raspberry Pi}} |
||
Line 296: | Line 297: | ||
To end not just the current process, but all processes in the same group, do <lang C>exit_group();</lang> |
To end not just the current process, but all processes in the same group, do <lang C>exit_group();</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|C++}}== |
=={{header|C++}}== |
||
Line 324: | Line 331: | ||
Note that returning a value from main is mostly equivalent to calling <tt>std::exit</tt> with the returned value, except that automatic variables are correctly destructed. If one wants to return from an inner function, while still doing complete cleanup, a solution is to throw an exception caught in main (this will call the destructors of non-main local variables during stack unwinding), and to then return normally from main (which will destruct all automatic objects in main, and then do the cleanup like <tt>std::exit</tt>. |
Note that returning a value from main is mostly equivalent to calling <tt>std::exit</tt> with the returned value, except that automatic variables are correctly destructed. If one wants to return from an inner function, while still doing complete cleanup, a solution is to throw an exception caught in main (this will call the destructors of non-main local variables during stack unwinding), and to then return normally from main (which will destruct all automatic objects in main, and then do the cleanup like <tt>std::exit</tt>. |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Clojure}}== |
=={{header|Clojure}}== |
||
Line 511: | Line 512: | ||
if problem -> |
if problem -> |
||
halt().</lang> |
halt().</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Forth}}== |
=={{header|Forth}}== |
||
Line 553: | Line 560: | ||
exit code is 1 |
exit code is 1 |
||
</pre> |
</pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Gambas}}== |
=={{header|Gambas}}== |
||
Line 735: | Line 736: | ||
(and the stack trace follows) |
(and the stack trace follows) |
||
</pre> |
</pre> |
||
⚫ | |||
⚫ | |||
=={{header|Groovy}}== |
=={{header|Groovy}}== |
||
Line 747: | Line 745: | ||
Solution #1: |
Solution #1: |
||
<lang groovy>if (problem) Runtime.runtime.halt(intExitCode)</lang> |
<lang groovy>if (problem) Runtime.runtime.halt(intExitCode)</lang> |
||
⚫ | |||
⚫ | |||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
Line 799: | Line 800: | ||
<lang javascript>if (some_condition) |
<lang javascript>if (some_condition) |
||
quit();</lang> |
quit();</lang> |
||
=={{header|jq}}== |
=={{header|jq}}== |
||
Line 897: | Line 897: | ||
The following is functional. Better practice is to instead jump to commands or subs to close known open files, windows etc, avoiding error messages as above. |
The following is functional. Better practice is to instead jump to commands or subs to close known open files, windows etc, avoiding error messages as above. |
||
<lang lb>if 2 =2 then end</lang> |
<lang lb>if 2 =2 then end</lang> |
||
=={{header|Logo}}== |
=={{header|Logo}}== |
||
{{works with|UCB Logo}} |
{{works with|UCB Logo}} |
||
Line 1,090: | Line 1,090: | ||
An exit without these cleanups can be done with <code>POSIX::_exit()</code> (as noted in <code>perlfunc.pod</code> under the normal <code>exit()</code>). This is the <code>_exit()</code> system call (which the C library generally provides in equivalent form on non-Unix/non-POSIX systems too). |
An exit without these cleanups can be done with <code>POSIX::_exit()</code> (as noted in <code>perlfunc.pod</code> under the normal <code>exit()</code>). This is the <code>_exit()</code> system call (which the C library generally provides in equivalent form on non-Unix/non-POSIX systems too). |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
Line 1,209: | Line 1,203: | ||
(custodian-shutdown-all (current-custodian))) |
(custodian-shutdown-all (current-custodian))) |
||
</lang> |
</lang> |
||
⚫ | |||
(formerly Perl 6) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|REBOL}}== |
=={{header|REBOL}}== |
||
Line 1,347: | Line 1,348: | ||
} |
} |
||
</lang> |
</lang> |
||
⚫ | |||
⚫ | |||
=={{header|Scheme}}== |
=={{header|Scheme}}== |
||
Line 1,384: | Line 1,382: | ||
Sys.exit(code); |
Sys.exit(code); |
||
}</lang> |
}</lang> |
||
=={{header|Simula}}== |
=={{header|Simula}}== |
||
<lang Simula>IF terminallyIll THEN terminate_program;</lang>»The procedure "terminate_program" terminates program execution. It closes SYSIN and SYSOUT. |
<lang Simula>IF terminallyIll THEN terminate_program;</lang>»The procedure "terminate_program" terminates program execution. It closes SYSIN and SYSOUT. |
||
It is implementation-dependent with respect to whether or not other open files are also closed.« [[http://simula67.at.ifi.uio.no/Standard-86/chap_10.htm| Simula Standard 86]] |
It is implementation-dependent with respect to whether or not other open files are also closed.« [[http://simula67.at.ifi.uio.no/Standard-86/chap_10.htm| Simula Standard 86]] |
||
⚫ | |||
⚫ | |||
=={{header|SNOBOL4}}== |
=={{header|SNOBOL4}}== |
||
Line 1,449: | Line 1,451: | ||
-> execution stops and message: |
-> execution stops and message: |
||
IF (condition==2) ERROR/STOP "condition ",condition, " Execution STOP "</lang> |
IF (condition==2) ERROR/STOP "condition ",condition, " Execution STOP "</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|UNIX Shell}}== |
=={{header|UNIX Shell}}== |
||
Line 1,466: | Line 1,462: | ||
fi |
fi |
||
exit 0 # Program terminated normally</lang> |
exit 0 # Program terminated normally</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Ursa}}== |
=={{header|Ursa}}== |
||
Line 1,477: | Line 1,479: | ||
If problem then Application.Quit |
If problem then Application.Quit |
||
'This will stop the application, but will prompt you to save work.</lang> |
'This will stop the application, but will prompt you to save work.</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|VBScript}}== |
=={{header|VBScript}}== |
||
Line 1,504: | Line 1,493: | ||
next |
next |
||
loop</lang> |
loop</lang> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
=={{header|Visual Basic}}== |
=={{header|Visual Basic}}== |