On Sunday 12 September 2004 19:18, Jerry Feldman wrote:
On Sun, 12 Sep 2004 18:03:56 -0400
"Steven T. Hatton"
wrote: I haven't dusted off my K&R to see what they have to say about
. I'm not completely sure what you mean by running in a different context. Very specifically, a signal handler does not share the same stack as the main program. it is very similar to an interrupt handler.
Almost like a separate thread. I guess it just sits there at the global level doing nothing until a throw causes the instruction pointer to branch to its entry point. I've notice nm show U _Unwind_Resume@@GCC_3.0 at the top of all the programs I've looked at. I assume that represents the entry address of the exception handler.
I'm a bit rusty on C++, but you can set up an exception handler to catch this type of exception.
C++ exception handling is, uh, interesting. Yes, you can switch out the exception handler, and you can also catch exceptions you threw from the same function, and throw them again, and again, and again......... ^C.
In essence, a divide by zero exception would result in a termination unless you specifically set up an exception handler for this.
But you have to have an exception to catch first. I'm fairly certain C++ does not generate an exception when you call a divide by zero. That's why I'm interested in the article. What it seems to amount to is OS calls to Windows are 'native C++'. Or something like that.
Java is a much different environment in that the language does not have a legacy signal mechanism. In Java, the signal from the OS is delivered to the JVM which then delivers it as an exception to your application.
Java's got it's good points. Are you using JBuilder? -- Regards, Steven