Exiting Your Program

Exiting Your Program — How to terminate a Glk program cleanly

Functions

void glk_exit ()

Includes

#include <libchimara/glk.h>

Description

A Glk program usually ends when the end of the glk_main() function is reached. You can also terminate it earlier.

Functions

glk_exit ()

void
glk_exit (void);

If you want to shut down your program in the middle of your glk_main() function, you can call glk_exit().

This function does not return.

If you print some text to a window and then shut down your program, you can assume that the player will be able to read it. Most likely the Glk library will give a “Hit any key to exit” prompt. (There are other possiblities, however. A terminal-window version of Glk might simply exit and leave the last screen state visible in the terminal window.)

You should only shut down your program with glk_exit() or by returning from your glk_main() function. If you call the ANSI exit() function, bad things may happen. Some versions of the Glk library may be designed for multiple sessions, for example, and you would be cutting off all the sessions instead of just yours. You would probably also prevent final text from being visible to the player.

Chimara

If there are any windows open at the time glk_exit() is called, then Chimara will leave them open. This way, the final text remains visible. Note that bad things most definitely will happen if you use the ANSI exit().