<chapter id="interrupt">
<title>Interrupting Commands</title>

<indexterm>
<primary>interrupting commands</primary>
</indexterm>

<para>
Commands can be interrupted, if the Go program supports it.
This is useful, for example, if the move generation takes a long time, to give
the user the ability to stop the current move generation and gain control over
the interface again.
</para>
    
<para>
There are two ways of sending the interrupt signal to the program:
</para>

<orderedlist>
<listitem>
<para>
The Go program reads the GTP input stream, while processing a command, and can
interrupt the current command, if the special comment line
<command>#&#160;interrupt</command> is received.
The Go program indicates this ability by implementing the command
<command>gogui_interrupt</command>.
</para>
</listitem>
<listitem>
<para>
The alternative way is that the program can handle INT signals.
It indicates this by implementing the <command>gogui_sigint</command>
command and returning its process ID.
GoGui will then send an INT signal to the process
by invoking the shell command
<userinput>kill -INT <replaceable>pid</replaceable></userinput>.
However, this will work only on UNIX systems and lacks the feature of
transmitting interrupt signals over network GTP streams.
</para>
</listitem>
</orderedlist>

<para>
If the program does not support any of these methods,
GoGui will offer to kill and detach the program.
</para>

<para><!-- Empty paragraph to enforce space in JEditorPane --></para>

</chapter>
