exit(0) crashing program

Hey all, I am trying to exit my program when the user enters 0. This will take the program to
1
2
3
4
5
void Hardware::endProgram()
{
	//program exits gracefully
	exit(0);
}

Where it should exit nice and easy just as if the program reaches the end of main. What it does though instead, is the window will stay open, not respond, then after about a minute will close. Any solutions?
Exit will normally call the destructors for any globals that were created (in reverse order). Make sure the destructors for your globals are bulletproof.


Attach a debugger when the program hangs and see where the control flow is.
Helios, I use visual studio's debugging tool. I use the debugger and breakpoints, etc and it executes the exit(0) and then just stays there. Assumingly to call the destructors as Abstract mentioned. I presume you mean a third party debugger...? If so, have any suggestions?
VS's debugger will do the trick.

After you call exit() and the program hangs... go in VS and press the "Break All" button (it looks like a Pause button). The debugger will snap on the line of code the program is currently executing (which, if you're in some kind of deadlock... will be in the deadlock).
Last edited on
Just hit the pause button while it's hanged like that, then. You can also find the command under Debug > Break on the menubar.
Topic archived. No new replies allowed.