SultanC
  1. Home
  2. Examples
  3. Processes

`exit` ends the program at once with the given status (here 3)

process/exit_code.sn
// `exit` ends the program at once with the given status (here 3).
import std.io.println;
import std.process.exit;

def main(): int {
    println("exiting with status 3");
    exit(3);
    println("never printed");
    return 0;
}

Run it

With the interpreter, without compiling:

./build/sultanc run examples/en/process/exit_code.sn

Or compile it to an executable:

./build/sultanc examples/en/process/exit_code.sn -o build/example && ./build/example

Source on GitHub   All examples