Running code on program termination #1783
Unanswered
olliejohnson
asked this question in
Q&A
Replies: 2 comments
-
I would wrap my code in a call and watch for the terminated error message. Edit: This snippet allows for tidy-up when main function errors. You can inspect the err message to see if it matches the terminated error message and thus do some special action on terminate. |
Beta Was this translation helpful? Give feedback.
0 replies
-
An alternative way would be to use os.pullEventRaw and thus not have the automatic termination error throwing. Your code will have to handle the terminate request event itself. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there a way to run a function when the program is terminated
Beta Was this translation helpful? Give feedback.
All reactions