Linux Web App - How to catch the kill signal

Hi,

I am running a linux standalone web application. When I kill the process, I don’t receive any event on Application Level. Is it nornal ? I expected, that the application close event will catch the kill signal, but nothing.

Are any other ways, to get the information that the Linux OS will kill the web application process ?

BR/Antonis

I don’t believe that SIGKILL(kill -9) can be captured. It stops the process and does not let it clean up. SIGTERM (kill -15 or just kill) allows the process to clean up but I’m not sure how it is done. I see that MonkeyBreadSoftware has a kit that can capture Linux signals but I don’t know which ones it can capture.

I tried with pKill xxxx, kill PID… I dont capture any event.

Any idea ?

How I will shutdown a standalone web application and the app.close event to catch it?

As Timothy noted, SIGKILL can’t be caught by a process. SIGTERM can be caught by processes with a signal handler, but signal handlers have some very stringent restrictions on what they can and can’t do. Specifically, they’re limited to setting global variables or calling async signal safe functions (see CERT’s SIG30-C for a much more in-depth explanation).

Any code using the Xojo runtime is not async signal safe, so a Xojo function cannot be set as a signal handler. Your best bet is probably to use a plugin for now and sign on to <https://xojo.com/issue/2332>.

We have a SignalHandlerMBS class in our plugins.
You can setup a signal to be ignored or raise an event.
Still as Joe says, if you call into Xojo code, your app can crash directly.
But I still use it for bug reporting which works quite well.

I need this too for my stand alone web app…

I need this for writing a RedHat system starter script to gracefully send signals to my web app.

I added the Feedback case (#2332) that Joe mentioned to My Top Cases in the Feedback app.

So how are others handling this for now, if not using the MB Plugin?

Via a bash script that receives signals and then checks for a .pid file and handles things appropriately, or ?

Normally, CancelClose should catch the terminate signal, right ?

Based on what others have said in this thread, no. And - that event isn’t available in Web or console apps.

CancelClose may see if you call Quit, but not a signal.