Use os::exit() to immediately terminate the process and exit with the given status. Any deferred functions will also get called before the process exits.
use fmt;
use os;
export fn main() void = {
defer fmt::println("narp")!;
os::exit(3);
};
$ hare run exit.ha
narp
$ hare build exit.ha
4/4 tasks completed (100%)
$ ./exit
narp
$ echo $?
3
Back to table of contents