Programming Guide |
Resets the display and exits
void sm_cancel(int arg);
arg
- A dummy argument that always has a value of 0. This argument lets the C function
signal
usesm_cancel
as a signal handler.
sm_initcrt installs this function to handle keyboard interrupts.
sm_cancel
calls sm_resetcrt to restore the display to the operating system's default state, and exits to the operating system.Depending on your operating system, you can also install this function to handle conditions that normally cause a program to abort. If a program aborts with
sm_cancel
installed, its call tosm_resetcrt
ensures that your terminal is restored to its normal state.
/* the following program segment could be found in
* some error routines */
#include <smdefs.h>
if (error)
{
sm_fquiet_err(0, "fatal error -- can't continue!\n");
sm_cancel(0);
}
/* The following code can be used on a UNIX system to
* install sm_cancel() as a signal handler. */
#include <smdefs.h>
#include <signal.h>
signal(SIGTERM, sm_cancel);