[ Operating System | Reference Manual | Alphabetic Index ]

# exit(+Status)

Exits and finalizes the executing ECLiPSe engine

Status
  A small integer

## Description

This predicate neither succeeds nor fails nor throws an exception. It terminates and finalizes the ECLiPSe engine on which it is executed, and leaves it in the exited(Status) state.

If the engine was started by an engine_resume/3 in another engine, the resume will return the exited(Status) state.

If the engine was started by an engine_resume_thread/2 and is being waited for by engine_join/3, this will return the exited(Status) state.

If the engine is embedded in a host program, control returns to the host program, indicating that the engine has exited with given status.

In a standalone executable, control will normally return to the operating system with the given status code.

Exit mechanism: exiting reliably frees all engine resources (apart from a small skeleton which disappears once all references are lost). This includes all resources referred to by handles that the engine owned. But note that no throw/1 operation is involved, so any recovery procedures in pending catch/3 invocations will not be executed.

### Modes and Determinism

- exit(+) is erroneous

### Exceptions

(4) instantiation fault
  Status is not instantiated.
(5) type error
  Status is instantiated to a non-integer.

## Examples

    Success:
          % Returning to a UNIX shell:
          ECLiPSe Constraint Logic Programming System [kernel]
          ...
          ?- exit(5).
          % echo $?
          5

          % Exiting from an auxiliary engine:
          ?- engine_create(E, []),
             engine_resume(E, exit(7), Status).
          E = $&(engine,"371ce7")
          Status = exited(7)
          Yes (0.00s cpu)

## See Also

engine_resume / 3, engine_resume_thread / 2, halt / 0