Catch an Event when app receives sigterm. Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
User avatar
mill-j
Earned a small fee
Earned a small fee
Posts: 23
Joined: Sat Jun 02, 2018 3:21 pm

Catch an Event when app receives sigterm.

Post by mill-j »

Hello.

I've been messing with wxwidgets off and on for several years now. I really like the documention and the samples and can almost always figure things out from them. But....

Anyways on to my problem: Does wx have any way to catch sigterm and create an event. I know under MSW and likely Mac there is a session end event that fires, but searching around, it looks like it doesn't work for Linux. Those threads are older so maybe this got added since then?

So if wxwidgets has no built in way of doing this, what would be the best way to implement this? All it needs to do is create a simple text file before shutdown. I know it's fairly simple to do as described here https://www.google.com/amp/s/airtower.w ... fully/amp/ but how to integrate it into wx?

Thanks.

mill-j
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: Catch an Event when app receives sigterm.

Post by DavidHart »

Hi,

You seem to have almost answered your own question: do something similar to that link. To see it working in a wx program, CodeLite, have a look at CodeLiteApp::OnInit in app.cpp; it's currently at line 276.

Once in the handler function (WaitForDebugger() in this case) you can do more or less what you like. Untested, but I don't see why that shouldn't include creating a text file.

Regards,

David
User avatar
mill-j
Earned a small fee
Earned a small fee
Posts: 23
Joined: Sat Jun 02, 2018 3:21 pm

Re: Catch an Event when app receives sigterm.

Post by mill-j »

:oops: You are correct. I missed this sentence
My Link wrote:This means that term() will be called when the program receives a SIGTERM.
Had I studied the code a little better, I would have seen that too.

I dropped it into a minimal sample and it works perfect. I can clean stuff up like I need, including my single instance checker.

Thanks for the links, it's always good to see a working example.
Post Reply