Jump to content
  • 0
Kyle R

App Cleanup On Exit

Question

Does a WBT App have a method for being notified when it is being deactivated by the system so that it can close handles, end sweeps, etc? 

Share this post


Link to post
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Thanks, that's a useful reference.

What about the case where the app is deactivated by the user via the WBT's App Manager window.  

Would SIGQUIT, SIGKILL or SIGTERM work for that situation?

​Looking at the code there's a slight disparity between how a gui app and non-gui app get closed.

A gui app receives a sigterm, and if it doesn't shut down after half a second it is forcibly terminated with sigkill.

A non-gui app receives a sighup (usually sent when the user running a program logs out), then after 200 ms a sigterm, then after another 100 ms a sigquit, then after a final 100 ms a sigkill.

Sigkill isn't catchable and is hard coded in the operating system to terminate the process, so the app has a limited time to shut down before it is forcibly terminated.

Share this post


Link to post
Share on other sites
  • 0

I don't believe that there's a function in the API that indicates when the system is shutting down, however when the operating system is shutting down it sends a SIGTERM signal to all programs, which the app can catch and use as an indicator to close gracefully.

 

Here's a quick linux signals tutorial if you're not familiar- http://www.yolinux.com/TUTORIALS/C++Signals.html

  • Upvote 1

Share this post


Link to post
Share on other sites
  • 0

Thanks, that's a useful reference.

What about the case where the app is deactivated by the user via the WBT's App Manager window.  

Would SIGQUIT, SIGKILL or SIGTERM work for that situation?

Share this post


Link to post
Share on other sites
  • 0

Thanks, that's a useful reference.

What about the case where the app is deactivated by the user via the WBT's App Manager window.  

Would SIGQUIT, SIGKILL or SIGTERM work for that situation?

​Yes.  Catching those signals should also work when the app is deactivated by the user

Share this post


Link to post
Share on other sites

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

×