9.3 Sending signals to running top-levels

When executing long running Prolog queries in the top-level, there may arise a need to interrupt the query, either to inspect the state of the top-level or to free it for running other queries. To signal a Sweep top-level that it should stop executing the current query and do something else instead, use the command sweeprolog-top-level-signal.

Command: sweeprolog-top-level-signal

Prompt for a Prolog goal and signal a top-level buffer to execute it.

This command prompts for an active Sweep top-level buffer followed by a Prolog goal, and interrupts the top-level causing it to run the specified goal.

C-c C-c
C-u C-c C-c

Interrupt the current Prolog top-level.

In a top-level buffer, you can use the command sweeprolog-top-level-signal-current to signal the current top-level. It is bound by default to C-c C-c. This command uses the value of the user option sweeprolog-top-level-signal-default-goal as the goal to signal, this is set by default to a goal that interrupts the top-level thread returns control of the top-level to the user. If you call sweeprolog-top-level-signal-current with a prefix argument (C-u C-c C-c), it prompts for the goal to signal.

You can also signal top-levels from the Sweep Top-level Menu buffer with the command sweeprolog-top-level-menu-signal with point at the entry corresponding to the wanted top-level (see The Top-level Menu buffer).

For more information about interrupting threads in SWI-Prolog, see Signaling threads in the SWI-Prolog manual.