Re: Determine where program is exiting from
On 7/23/2014 1:02 PM, Marcel Mueller wrote:
On 23.07.14 18.50, ?? Tiib wrote:
On Wednesday, 23 July 2014 19:25:32 UTC+3, Christopher Pisz wrote:
I've got a service kind of console application. It shouldn't exit until
I go and kill it. It seems to be exiting with a return of 0 prematurely
and I am not sure why or how.
Is there some kind of callback/handler type thing I can override to put
a breakpoint and see where is it exiting from? Like I've done for pure
virtual function calls. or is that Windows specific?
Program can set exit handler with 'atexit' and terminate handler with
'set_terminate'.
I am unsure whether this helps, since the call stack of exit might
already be lost at this place.
....especially is the 'terminate' handler is called because of an
unhandled exception.
A full text search for \wexit\( (Regex) over the entire source code
could be helpful. This won't work if exit is called from a library.
Another dirty hack: write a custom function exit(int) and place the
breakpoint there. Of course, this is platform dependent, but usually the
linker prefers this function over the one in the runtime library.
I think you already checked for the trivial case: return from main.
A Windows service is a bunch of callbacks that are registered with the
"Service Manager" for its use, each operation (start, stop) is a call to
some function, IIRC. Return from 'main' doesn't actually make the
service quit, methinks; the Manager keeps it "on hold."
If memory serves, it's possible to debug a service, if you run it under
a debugger. Visual Studio debugger allows you to suspend execution if
any of 5 classes of exceptions is thrown.
V
--
I do not respond to top-posted replies, please don't ask