Jump to content
  • Advertisement
Sign in to follow this  
Stormtrooper

cmd promp window?

This topic is 3916 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!