A signal when a user kills a process?

I overloaded the 6 signals listed on this site http://www.cplusplus.com/reference/clibrary/csignal/signal.html

Then I launched my application (double click did not go through the IDE) and tried 1) to complete the task 2) X to topright and 3) kill the process. I expected the first two to trigger some kind of signal (I'm on XP), but alas, I got nothing. Am I not allowed to open files for recording when a signal occurs? I guess I (SIGSEGV allowed me).

When firefox crashes or when I kill it, it remembers which pages I was on. Does it register every time every time I click on the page, or does it do this on a signal / crash?

My main question is what signal can I use to capture the processing process.

+3
source share
3 answers

Win32 does not provide the ability to intercept your program that is being killed using TerminateProcess(what will happen when you "Finish the task" from the task manager or click on [X]).

You can catch the SIGSEGV signal because the C runtime library emulates this signal when running on Windows. When your program causes a Windows access violation (exception 0xC0000005), the runtime library has the ability to catch this and mimic the Unix style for SIGSEGV. This, however, is not the best way to deal with such an exception. If you are writing a Win32 program, usually you should not use Unix style services.

+4

, , , SetUnhandledExceptionFilter ( win32 , , C). "-" .

, . Windows TerminateProcess, , .

, Firefox, , , , , , - .

, ( ), , , , , , , .

+1

Windows - , . , , WM_CLOSE, CTRL_CLOSE_EVENT. ; , TerminateProcess().

If you want to save where you were, use a memory mapped file and update it for each action. When your process ends, a dirty page in memory is written back to the OS file, possibly at other times. This solution allows the OS to manage disk I / O for you, and it is in a better position for this.

0
source

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


All Articles