Jump to content
  • Advertisement
Sign in to follow this  
DividedByZero

Executing code after console is closed

This topic is 3631 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

Advertisement
Not after closing, of course. Make sure that the control flow of your program is clean (RAII for example, in c++).

You could write a signal handler in case of a SIGTERM (though I don't know the details on windows).

Share this post


Link to post
Share on other sites
This is platform dependent. For example, on Windows, by default, closing the console window with the close window button will cause the program to terminate immediately via ExitProcess(), without unwinding the stack (meaning RAII won't handle cleanup for you) or calling any of the atexit handlers. You can, however, register a handler routine with SetConsoleCtrlHandler() to process CTRL_CLOSE_EVENT to perform actions when the console is closed.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
(meaning RAII won't handle cleanup for you)


Oh I didn't mean it like that. More completly I wanted to say "If the OS decided to kill your app immediately (like with a unix SIGKILL), you can't do anything. Just ensure to have a clean CFG and proper signal handlers for a quiet conscience".

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!