2.4.1 Exit status

Some operating systems have the notion of exit status of a process. In such systems, by default the execution of the particular program results in an exit status of success. It is possible for the program to specify an explicit exit status by using the standard procedure set exit status, like:

begin # ... program code ... #
     if error found;
     then set exit status (1) fi
end

In POSIX systems the status is an integer, and the system interprets a value other than zero as a run-time error. In other systems the status may be of some other type. To support this, the set error status procedure accepts as an argument an united value that accommodates all the supported systems.

The following example shows a very simple program that prints “Hello world” on the standard output and then returns to the operating system with a success status:

begin puts ("Hello world\n")
end