• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

4.37 User Top-level Manipulation
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Built-in Predicates
        • User Top-level Manipulation
          • break/0
          • abort/0
          • halt/0
          • halt/1
          • prolog/0
          • expand_query/4
          • expand_answer/3
          • expand_answer/2
    • Packages
Availability:built-in
[ISO]halt(+Status)
Terminate Prolog execution with Status. When possible, raise the exeption unwind(halt(Status)). Currently, this is used when halt/1 is called in the main thread and there is no intermediate C function on the stack that called PL_next_solution() without the PL_Q_PASS_EXCEPTION flag. Future versions may also use signal based exit from threads.

After the exception bubbled up to the top or if the halt exeption could not be raised, system termination starts. System termination (see also PL_halt()) preforms the following steps:

  1. Set the Prolog flag exit_status to Status.

  2. Call all hooks registered using at_halt/1. If Status equals 0 (zero), any of these hooks calls cancel_halt/1, termination is cancelled.

  3. Call all hooks registered using PL_at_halt(). In the future, if any of these hooks returns non-zero, termination will be cancelled. Currently, this only prints a warning.

  4. Perform the following system cleanup actions:

    • Raise unwind(halt(Status)) in all running threads.
    • Wait for a maximum of 1 second for all threads to respond to this exception. Registered thread_at_exit/1 hooks are executed. Threads not responding within 1 second are cancelled forcefully.
    • Flush I/O and close all streams except for standard I/O.
    • Reset the terminal if its properties were changed.
    • Remove temporary files and incomplete compilation output.
    • Reclaim memory.

  5. Call exit(Status) to terminate the process

halt/1 has been extended in SWI-Prolog to accept the arg abort. This performs as halt/1 above except that:

  • Termination cannot be cancelled with cancel_halt/1.
  • abort() is called instead of exit(Status).

In addition to an integer status name we also allow passing a signal name. This is similar to abort, blocking halt cancellation and set the termination code to 128+signum. For example, using halt(term) the system exits with status 143 (= 128+15) on Linux.

ClioPatria (version V3.1.1-51-ga0b30a5)