[comp.sys.mac.programmer] How can we catch signals using MacOS ?

ivan@metasoft.UUCP (Ivan Hajadi) (01/03/90)

I am porting an application from SunOS to MacOS.  I use Think C 4.0 on
Mac SE/30.  I need to be able to catch a trap on minus condition.  I
am able to do this in unix using signal system call to install my
handler (see enclosed codes).  The signal function available in the
unix library of Think C seems to be bogus.  As far as I know if trapmi
is executed, then MacOS will simply draw a bomb with id=12(?).

Is there anyway I can tell the MacOS to call my routine, when trapmi
instruction is executed by the processor and avoid the bomb ?

This is how I do it on unix:

When the program starts, it calls setupsignals().
setupsignals()
{
	signal(SIGFPE, ghandle);
	...
}


When trapmi instruction encountered, my ghandle function will be called.

ghandle(int signal,......)
{
	if (signal == SIGFPE)
	{
	}
	....
}


I appreciate any suggestion.  Thank you.

-- ivan