/*
 * 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1986,1988
 * LICENSED MATERIALS - PROPERTY OF IBM
 * REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
 */
/* $Header:sys2.c 12.0$ */
/* $ACIS:sys2.c 12.0$ */
/* $Source: /ibm/acis/usr/sys/standca/RCS/sys2.c,v $ */

#ifndef lint
static char *rcsid = "$Header:sys2.c 12.0$";
#endif

static exit_rc = 1;		/* in case _stop gets called directly */
extern int _init_kbd;

exit(n)
{
	exit_rc = n;		/* remember how we exited */
	_stop("Exit called");
}


static int dummy() {
}


               ;

typedef int (*fn)();

fn exitaddr = dummy;

setexit(addr)
	fn addr;
{
	exitaddr = addr;
}

char _stopmsg[1];
int _noputchar;

_stop(s)
	char *s;
{
	_noputchar = 0;			/* allow error message to print */
	(*exitaddr)();
	printf("%s %s\n", s, _stopmsg);
	if (exit_rc)
		clear_kbd(100);
	else
		exit_rc = 1;
	getchar();
	_init_kbd = 0;		/* reset the init keyboard flag */
	start();
}


#ifndef ibm032
trap(ps)
	int ps;
{
	printf("Trap %o\n", ps);
	for (;;);
}


#endif
