How to determine the strength of a java program to close from windows task manager?

Guys, I'm sorry if I insulted someone by asking such a noob question, as I see that someone has a "Denied" question for being inappropriate.

This is my first time asking here, so forgive me if something does not fit, and sorry if my English is not very good.

I am trying to create a temporary file when my program was closed through the task manager ... but I have no idea how to determine if my program is closed through the task manager !!!

How can I do it? I googled a lot, but either I used the wrong keywords or there are no easy solutions on the Internet. I hope someone here can help me.

Best wishes and thanks.

+6
source share
1 answer

To catch regular termination requests, such as SIGTERM or WM_CLOSE , sent using the Applications tab of the task manager, a shutdown hook can be set (I assume you are using Windows, but that doesn’t make much difference).

However, when killing from the "processes" tab or using taskkill /f ... on Windows or kill -9 ... on Linux or Unix, the process (VM) is forcibly terminated, it cannot respond. The same thing can be said about the killings carried out with the help of "non-responding" dialog boxes in Windows.

Thus, you need to make sure that you can process files that are damaged / incomplete as a result of forced destruction (in addition to power failures or hardware failures).

+5
source

Source: https://habr.com/ru/post/958330/


All Articles