Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,5 @@
---
category:
- Simple
from: http://rosettacode.org/wiki/Program_termination
note: Basic language learning

View file

@ -0,0 +1,9 @@
;Task:
Show the syntax for a complete stoppage of a program inside a   [[Conditional Structures|conditional]].
This includes all [[threads]]/[[processes]] which are part of your program.
Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks, etc.).
Unless otherwise described, no special cleanup outside that provided by the operating system is provided.
<br><br>

View file

@ -0,0 +1,2 @@
I problem
exit(1)

View file

@ -0,0 +1,5 @@
;assuming this is not a subroutine and runs inline.
cmp TestValue ;a label for a memory address that contains some value we want to test the accumulator against
beq continue
rts ;unlike the Z80 there is no conditional return so we have to branch around the return instruction.
continue:

View file

@ -0,0 +1,3 @@
sei ;disable IRQs
halt:
jmp halt ;trap the program counter

View file

@ -0,0 +1,35 @@
/* ARM assembly AARCH64 Raspberry PI 3B */
/* program ending64.s */
/*******************************************/
/* Constantes file */
/*******************************************/
/* for this file see task include a file in language AArch64 assembly*/
.include "../includeConstantesARM64.inc"
/*******************************************/
/* Initialized data */
/*******************************************/
.data
/*******************************************/
/* code section */
/*******************************************/
.text
.global main
main: // entry of program
OK:
// end program OK
mov x0,0 // return code
b 100f
NONOK:
// if error detected end program no ok
mov x0,1 // return code
100: // standard end of the program
mov x8,EXIT // request to exit program
svc 0 // perform the system call Linux
/********************************************************/
/* File Include fonctions */
/********************************************************/
/* for this file see task include a file in language AArch64 assembly */
.include "../includeARM64.inc"

View file

@ -0,0 +1,3 @@
IF problem = 1 THEN
stop
FI

View file

@ -0,0 +1 @@
if anErrorOccured then assert( false );

View file

@ -0,0 +1,22 @@
#!/usr/local/bin/apl --script --
⍝⍝ GNU APL script
⍝⍝ Usage: errout.apl <code>
⍝⍝
⍝⍝ $ echo $? ## to see exit code
⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝⍝
args 2⎕ARG~'--script' '--' ⍝⍝ strip off script args we don't need
err args[1]
main
(0=err)/ok
error:
'Error! exiting.'
')off 1' ⍝⍝ NOTE: exit code arg was added to )OFF in SVN r1499 Nov 2021
ok:
'No error, continuing...'
')off'
main

View file

@ -0,0 +1,26 @@
/* ARM assembly Raspberry PI */
/* program ending.s */
/* Constantes */
.equ EXIT, 1 @ Linux syscall
/* Initialized data */
.data
/* code section */
.text
.global main
main: @ entry of program
push {fp,lr} @ saves registers
OK:
@ end program OK
mov r0, #0 @ return code
b 100f
NONOK:
@ if error detected end program no ok
mov r0, #1 @ return code
100: @ standard end of the program
pop {fp,lr} @restaur registers
mov r7, #EXIT @ request to exit program
swi 0 @ perform the system call Linux

View file

@ -0,0 +1 @@
if(problem)exit 1

View file

@ -0,0 +1,9 @@
# usage: awk -f exittest.awk input.txt
BEGIN { print "# Exit-Test" }
#/s.*t/ { print "!", NR, $0; next } #1: List all matches
/s.*t/ { print "!", NR, $0; problem=1; exit} #2: Abort after first match
{ print " ", NR, $0}
END { if(problem) {print "!! Problem !!"; exit 2} }
END { print "# Lines read:", NR }

View file

@ -0,0 +1,9 @@
PROC Main()
DO
IF Rand(0)=10 THEN
PrintE("Terminate program by Break() procedure")
Break()
FI
OD
PrintE("This is a dead code")
RETURN

View file

@ -0,0 +1,10 @@
with Ada.Task_Identification; use Ada.Task_Identification;
procedure Main is
-- Create as many task objects as your program needs
begin
-- whatever logic is required in your Main procedure
if some_condition then
Abort_Task (Current_Task);
end if;
end Main;

View file

@ -0,0 +1,11 @@
procedure Main is
-- Create as many task objects as your program needs
begin
-- whatever logic is required in your Main procedure
if some_condition then
-- for each task created by the Main procedure
The_task.Stop;
-- end the Main procedure
return; -- actually, this is not needed
end if;
end Main;

View file

@ -0,0 +1,14 @@
task body Some_Task is
begin
loop
select
-- Some alternatives
...
or accept Stop do
-- Some cleanup while holding the caller is here
end Stop;
-- A cleanup asynchronous to the caller is here
exit; -- We are through
end select
end loop;
end Some_Task;

View file

@ -0,0 +1,10 @@
task body Some_Task is
begin
loop
select
-- Some alternatives
...
or terminate; -- We are through
end select
end loop;
end Some_Task;

View file

@ -0,0 +1,15 @@
void
f1(integer a)
{
if (a) {
exit(1);
}
}
integer
main(void)
{
f1(3);
return 0;
}

View file

@ -0,0 +1 @@
if (someCondition) then error number -128

View file

@ -0,0 +1,9 @@
on idle -- A stay-open applet's 'idle' handler is called periodically while the applet remains open.
-- Some code, including:
if (someCondition) then
quit -- Quit the applet when the script stops executing.
error number -128 -- Stop executing the script. (Not necessary on recent systems.)
end if
return 10 -- Number of seconds to the next call of this handler if the applet's still open.
end idle

View file

@ -0,0 +1 @@
10 IF 1 THEN STOP

View file

@ -0,0 +1,3 @@
problem: true
if problem -> exit

View file

@ -0,0 +1,2 @@
If (problem)
ExitApp

View file

@ -0,0 +1,3 @@
If problem Then
Exit
Endif

View file

@ -0,0 +1 @@
Returnʳ

View file

@ -0,0 +1,3 @@
if problem = 1 then
end
end if

View file

@ -0,0 +1 @@
IF condition% THEN QUIT

View file

@ -0,0 +1,4 @@
{
0=•args ? •Exit 0;
•Show "has args"
}

View file

@ -0,0 +1 @@
IF TRUE THEN END 42

View file

@ -0,0 +1 @@
if condition exit

View file

@ -0,0 +1 @@
_@

View file

@ -0,0 +1,6 @@
#include <cstdlib>
void problem_occured()
{
std::exit(EXIT_FAILURE);
}

View file

@ -0,0 +1,6 @@
#include <cstdlib>
void problem_occured()
{
std::abort();
}

View file

@ -0,0 +1,6 @@
#include <exception>
void problem_occured()
{
std::terminate();
}

View file

@ -0,0 +1,4 @@
if (problem)
{
Environment.Exit(1);
}

View file

@ -0,0 +1,18 @@
#include <stdlib.h>
/* More "natural" way of ending the program: finish all work and return
from main() */
int main(int argc, char **argv)
{
/* work work work */
...
return 0; /* the return value is the exit code. see below */
}
if(problem){
exit(exit_code);
/* On unix, exit code 0 indicates success, but other OSes may follow
different conventions. It may be more portable to use symbols
EXIT_SUCCESS and EXIT_FAILURE; it all depends on what meaning
of codes are agreed upon.
*/
}

View file

@ -0,0 +1,5 @@
#include <stdlib.h>
if(problem){
abort();
}

View file

@ -0,0 +1 @@
exit_group();

View file

@ -0,0 +1,3 @@
IF problem
STOP RUN
END-IF

View file

@ -0,0 +1,3 @@
IF problem
GOBACK
END-IF

View file

@ -0,0 +1,6 @@
(if problem
(. System exit integerErrorCode))
;conventionally, error code 0 is the code for "OK",
; while anything else is an actual problem
;optionally: (-> Runtime (. getRuntime) (. exit integerErrorCode))
}

View file

@ -0,0 +1,4 @@
(if problem
(-> Runtime (. getRuntime) (. halt integerErrorCode)))
; conventionally, error code 0 is the code for "OK",
; while anything else is an actual problem

View file

@ -0,0 +1,11 @@
(defun terminate (status)
#+sbcl ( sb-ext:quit :unix-status status) ; SBCL
#+ccl ( ccl:quit status) ; Clozure CL
#+clisp ( ext:quit status) ; GNU CLISP
#+cmu ( unix:unix-exit status) ; CMUCL
#+ecl ( ext:quit status) ; ECL
#+abcl ( ext:quit :status status) ; Armed Bear CL
#+allegro ( excl:exit status :quiet t) ; Allegro CL
#+gcl (common-lisp-user::bye status) ; GCL
#+ecl ( ext:quit status) ; ECL
(cl-user::quit)) ; Many implementations put QUIT in the sandbox CL-USER package.

View file

@ -0,0 +1,53 @@
import core.stdc.stdio, core.stdc.stdlib;
extern(C) void foo() nothrow {
"foo at exit".puts;
}
extern(C) void bar() nothrow {
"bar at exit".puts;
}
extern(C) void spam() nothrow {
"spam at exit".puts;
}
int baz(in int x) pure nothrow
in {
assert(x != 0);
} body {
if (x < 0)
return 10;
if (x > 0)
return 20;
// x can't be 0.
// In release mode this becomes a halt, and it's sometimes
// necessary. If you remove this the compiler gives:
// Error: function test.notInfinite no return exp;
// or assert(0); at end of function
assert(false);
}
// This generates an error, that is not meant to be caught.
// Objects are not guaranteed to be finalized.
int empty() pure nothrow {
throw new Error(null);
}
static ~this() {
// This module destructor is never called if
// the program calls the exit function.
import std.stdio;
"Never called".writeln;
}
void main() {
atexit(&foo);
atexit(&bar);
atexit(&spam);
//abort(); // Also this is allowed. Will not call foo, bar, spam.
exit(0);
}

View file

@ -0,0 +1,21 @@
import core.runtime, std.c.stdlib;
static ~this() {
// This module destructor is called if
// the program calls the dexit function.
import std.stdio;
"Called on dexit".writeln;
}
void dexit(int rc) {
// Calling dexit() should have the same effect with regard to cleanup as as reaching the end of the main program.
Runtime.terminate();
exit(rc);
}
int main() {
if(true) {
dexit(0);
}
return 0;
}

View file

@ -0,0 +1 @@
IF (CONDITION) STOP

View file

@ -0,0 +1 @@
System.Halt;

View file

@ -0,0 +1 @@
System.Halt(1); // Optional exit code

View file

@ -0,0 +1,3 @@
if (true) {
interp.exitAtTop()
}

View file

@ -0,0 +1,3 @@
if (true) {
interp.exitAtTop("because the task said so")
}

View file

@ -0,0 +1,6 @@
^| I try to use the exit codes described at:
| https://github.com/openbsd/src/blob/master/include/sysexits.h
|^
int EX_SOFTWARE = 70 # internal software error
logic hasProblem = true
if hasProblem do exit EX_SOFTWARE end

View file

@ -0,0 +1 @@
if rcode != :ok, do: System.halt(1)

View file

@ -0,0 +1,3 @@
exit(:normal)
# or
exit(:shutdown)

View file

@ -0,0 +1,2 @@
(when something
(kill-emacs))

View file

@ -0,0 +1,3 @@
% Implemented by Arjun Sunel
if problem ->
exit(1).

View file

@ -0,0 +1,3 @@
% Implemented by Arjun Sunel
if problem ->
halt().

View file

@ -0,0 +1,4 @@
open System
if condition then
Environment.Exit 1

View file

@ -0,0 +1,3 @@
USING: kernel system ;
t [ 0 exit ] when

View file

@ -0,0 +1,3 @@
USING: init io ;
[ "Exiting Factor..." print flush ] "message" add-shutdown-hook

View file

@ -0,0 +1,4 @@
debug @
if QUIT \ quit back to the interpreter
else BYE \ exit forth environment completely (e.g. end of a Forth shell script)
then

View file

@ -0,0 +1,3 @@
IF (condition) STOP [message]
! message is optional and is a character string.
! If present, the message is output to the standard output device.

View file

@ -0,0 +1,11 @@
'FB 1.05.0 Win64 'endprog.bas'
Dim isError As Boolean = True
If isError Then
End 1
End If
' The following code won't be executed
Print
Print "Press any key to quit"
Sleep

View file

@ -0,0 +1 @@
10 IF 1 THEN STOP

View file

@ -0,0 +1,11 @@
Public Sub Form_Open()
Dim siCount As Short
Do
If siCount > 1000 Then Break
Inc siCount
Loop
Me.Close
End

View file

@ -0,0 +1,11 @@
Public Sub Main()
Dim siCount As Short
Do
If siCount > 1000 Then Break
Inc siCount
Loop
Quit
End

View file

@ -0,0 +1 @@
Star Trek=@err{found a Star Trek reference\n}@abort

View file

@ -0,0 +1,4 @@
problem=1
if (problem) {
exit gnuplot
}

View file

@ -0,0 +1,5 @@
func main() {
if problem {
return
}
}

View file

@ -0,0 +1,46 @@
package main
import (
"fmt"
"runtime"
"time"
)
const problem = true
func main() {
fmt.Println("main program start")
// this will get run on exit
defer paperwork()
// this will not run to completion
go pcj()
// this will not get run on exit
rec := &requiresExternalCleanup{"external object"}
runtime.SetFinalizer(rec, cleanup)
if problem {
fmt.Println("main program returning")
return
}
}
func paperwork() {
fmt.Println("i's dotted, t's crossed")
}
func pcj() {
fmt.Println("there's uncle Joe")
time.Sleep(1e10)
fmt.Println("movin kinda slow")
}
type requiresExternalCleanup struct {
id string
}
func cleanup(rec *requiresExternalCleanup) {
fmt.Println(rec.id, "cleanup")
}

View file

@ -0,0 +1,13 @@
func main() {
fmt.Println("main program start")
// this will not get run on os.Exit
defer func() {
fmt.Println("deferred function")
}()
if problem {
fmt.Println("main program exiting")
os.Exit(-1)
}
}

View file

@ -0,0 +1,17 @@
func pcj() {
fmt.Println("at the junction")
defer func() {
fmt.Println("deferred from pcj")
}()
panic(10)
}
func main() {
fmt.Println("main program start")
defer func() {
fmt.Println("deferred from main")
}()
go pcj()
time.Sleep(1e9)
fmt.Println("main program done")
}

View file

@ -0,0 +1 @@
if (problem) System.exit(intExitCode)

View file

@ -0,0 +1 @@
if (problem) Runtime.runtime.halt(intExitCode)

View file

@ -0,0 +1,8 @@
import Control.Monad
import System.Exit
when problem do
exitWith ExitSuccess -- success
exitWith (ExitFailure integerErrorCode) -- some failure with code
exitSuccess -- success; in GHC 6.10+
exitFailure -- generic failure

View file

@ -0,0 +1 @@
ALARM( 999 )

View file

@ -0,0 +1 @@
100 IF CONDITION THEN STOP

View file

@ -0,0 +1,3 @@
exit(i) # terminates the program setting an exit code of i
stop(x1,x2,..) # terminates the program writing out x1,..; if any xi is a file writing switches to that file
runerr(i,x) # terminates the program with run time error 'i' for value 'x'

View file

@ -0,0 +1 @@
2!:55^:] condition

View file

@ -0,0 +1 @@
3 : 'if. 0~: condition do. 2!:55 condition end.'

View file

@ -0,0 +1,6 @@
if(problem){
System.exit(integerErrorCode);
//conventionally, error code 0 is the code for "OK",
// while anything else is an actual problem
//optionally: Runtime.getRuntime().exit(integerErrorCode);
}

View file

@ -0,0 +1,5 @@
if(problem){
Runtime.getRuntime().halt(integerErrorCode);
//conventionally, error code 0 is the code for "OK",
// while anything else is an actual problem
}

View file

@ -0,0 +1,2 @@
if (some_condition)
quit();

View file

@ -0,0 +1 @@
[true] [quit] [] ifte.

View file

@ -0,0 +1,2 @@
$ jq -n '"Hello", if 1 then error else 2 end'
"Hello"

View file

@ -0,0 +1,2 @@
$ jq -n '"Hello" | if 1 then error else 2 end'
jq: error: Hello

View file

@ -0,0 +1,3 @@
assert(0 == 1);
if (problem) exit(1);

View file

@ -0,0 +1 @@
quit() # terminates program normally, with its child processes. See also exit(0).

View file

@ -0,0 +1,7 @@
// version 1.0.6
fun main(args: Array<String>) {
val problem = true
if (problem) System.exit(1) // non-zero code passed to OS to indicate a problem
println("Program terminating normally") // this line will not be executed
}

View file

@ -0,0 +1,12 @@
#!/usr/bin/lasso9
//[
handle => {
stdoutnl('The end is here')
}
stdoutnl('Starting execution')
abort
stdoutnl('Ending execution')

View file

@ -0,0 +1,12 @@
#!/usr/bin/lasso9
handle_error => {
stdoutnl('There was an error ' + error_msg)
abort
}
stdoutnl('Starting execution')
0/0
stdoutnl('Ending execution')

View file

@ -0,0 +1 @@
if 2 =2 then end

View file

@ -0,0 +1 @@
10 IF 1 THEN END

View file

@ -0,0 +1,6 @@
bye ; exits to shell
throw "toplevel ; exits to interactive prompt
pause ; escapes to interactive prompt for debugging
continue ; resumes after a PAUSE

View file

@ -0,0 +1,3 @@
if some_condition then
os.exit( number )
end

View file

@ -0,0 +1,17 @@
Module Checkit {
For i=1 to 200
Thread {
k++
Print "Thread:"; num, "k=";k
} as M
Thread M Execute {
static num=M, k=1000*i
}
Thread M interval 100+900*rnd
next i
Task.Main 20 {
if random(10)=1 then Set End
}
}
Checkit

View file

@ -0,0 +1,4 @@
beginning
define(`problem',1)
ifelse(problem,1,`m4exit(1)')
ending

View file

@ -0,0 +1,3 @@
if condition
return
end

View file

@ -0,0 +1,3 @@
if condition
quit
end

View file

@ -0,0 +1 @@
If[problem, Abort[]];

View file

@ -0,0 +1,6 @@
/* Basically, it's simply quit() */
block([ans], loop, if (ans: read("Really quit ? (y, n)")) = 'y
then quit()
elseif ans = 'n then (print("Nice choice!"), 'done)
else (print("I dont' understand..."), go(loop)));

Some files were not shown because too many files have changed in this diff Show more