Home > OS > How Windows before the process is killed by the task manager to do some processing
How Windows before the process is killed by the task manager to do some processing
Time:10-13
Run into a more depressed, I have a process, the runtime dynamically allocated the 1-4 process (these processes have no source, immutable), in my main process was killed by the task manager, to ensure that the child was killed at the same time, I realized through signal mechanism at first, later found by semaphore cannot capture the end of the process in task manager semaphore, then know that this is achieved by the TerminateProcess, so now the thought of the method is to hook the TerminateProcess before system call TerminateProcess, through the process of communication between, and I in the main process to create a thread to interact, thread after receiving the message, to kill the child, and then tell the hook function, already ok, now hook function calls the TerminateProcess function of the system, and close the main process, Don't know if you have what good method, I think it is very trouble, but can't think of another good way to,
CodePudding user response:
Can not be in their own WM_CLOSE handled? Should be receiving this message