Sign in to follow this  

cmd promp window?

This topic is 3629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm writing a server program, and was wondering how to make it so when you click the x (in Windows atleast) the application properly closes and doesn't immediately close without doing any cleanup.

Share this post


Link to post
Share on other sites
What do you mean by cleanup? Your application should have it's own way to properly exit if you need to do any cleanup in my opinion.

BTW, clicking close does properly terminate the program for the OS (but not always so for the application).

Share this post


Link to post
Share on other sites
Basically...I have a game loop which is inside a class. If I click exit while inside the game loop, it skips the deconstructor, and the rest of the code in main(). Should I implement a way to exit without needing to click exit? I am planning to make the server run on Linux aswell, BTW.

Share this post


Link to post
Share on other sites
When you click the x, you will eventually get WM_DESTROY. In that message you should destroy your class.

Edit:

If you are using a command prompt window then you will need to set a console control handler using SetConsoleCtrlHandler() to intercept CTRL_CLOSE_EVENT and destroy your class there.

Share this post


Link to post
Share on other sites
Quote:
Original post by Stormtrooper
I am planning to make the server run on Linux aswell, BTW.
For linux you can use signal to handle the SIGTERM signal then use the kill command to end the process. If you want to close a terminal window with your server running in it I think you will receive the SIGHUP signal, but I am not sure about that.

Share this post


Link to post
Share on other sites

This topic is 3629 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this