Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!watmath!watnot!djfiander
From: djfiander@watnot.UUCP
Newsgroups: comp.sys.ibm.pc
Subject: Re: MSC signal() and free() problems
Message-ID: <12341@watnot.UUCP>
Date: Tue, 13-Jan-87 10:37:25 EST
Article-I.D.: watnot.12341
Posted: Tue Jan 13 10:37:25 1987
Date-Received: Wed, 14-Jan-87 07:25:39 EST
References: <558@vu-vlsi.UUCP> <117@interlan.UUCP>
Reply-To: djfiander@watnot.UUCP (David Fiander)
Organization: U. of Waterloo, Ontario
Lines: 21

>>I'm having trouble with a ^C handler using MSC 4.0 and PC-DOS 3.1.  I have
>>signal(SIGINT, interrupt); to call my routine interrupt() when ^C is pressed.
>>This works as expected, but sometimes bombs out with a stack overflow.
>
>	The reason you are getting DOS's stack is that you are trapping an
>	interrupt!  When ^C is hit, the SIGINT function will call your routine
>	as an interrupt handler .  It is your responsibility  as an interrupt
>	routine to set up your environment correctly.
>

I don't think very much of the idea that a system routine that was obviously
designed to call a C routine (otherwise just set up the INT vector yourself)
doesn't set the stack pointer to the required data segment.  The
interrupt() function is _not_ an interrupt function.  The signal() function
sets the SIGINT vector to point to a hidden bit of code in the library which
calls interrupt().  I don't know this for a fact, but it seems reasonable, 
since the description of signal() in the msc documentation says that the 
interrupt vector is reset to the default after each call to the user routine.

-David J. Fiander (watmath!watnot!djfiander)
"What now Boss?"