Home > OS >  The TerminateProcess will cause the child to hang
The TerminateProcess will cause the child to hang

Time:10-02

A strange problems at present, there is A main process A, will create some thread, the child thread invokes the CreateProcess create A child process, after the child to do something will create A text file is written to the content, the child thread WaitForSingleObject waiting for it to create the child over, waiting for the longest time 1 minute, then get the child to create text, if not return the child process in 1 minute, will the child thread invokes the TerminateProcess terminate it, the operation of the child process will not be blocked, in theory, even if the end of the main process A, it's the child thread to create the child process will end itself, but the question now is, call the TerminateProcess main process over A moment, the child process is put up, the problem is not now, the chance is not high also, but several times, is can cause the child to hang the TerminateProcess way? Is there any good way to ensure A process is after the Kill, all the child process to exit?

CodePudding user response:

"Windows programming revelation"
In 19.6 why some processes are terminated after still stays in the task manager
When the end of a process (end of may be normal, it may also be because calls like the TerminateProcess function), the process of user mode module will be deleted, but only in the kernel configuration module is associated with the thread of all drivers will be deleted after completion of execution,
For example, if a thread is in the midst of the I/O operations, so will give responsible for the I/O driver sends a kernel signal to cancel the operation,
If the driver's behavior is good, then it will be cleared with the outstanding I/O and some information about the release thread,
If the driver's behavior is not good (probably because the hardware driver management appears strange behavior), you may need to take a long time to clear the outstanding I/O, in this time, the driver will not release the thread (and) the thread's process, the actual situation is more complicated, but this simple model is sufficient for our discussion,
.
, in other words, if you stopped after a process can also see the process in task manager, so, in fact, the process has stopped running, but also some of the residual information retained in the system, only when all drivers are associated with the process to complete the cleaning operation and points to handle to the process have closed, the process will disappear completely,

CodePudding user response:

The child process operation will not be blocked, but sometimes it is more than the expected maximum execution time of 1 minute; I think I should attatch check on the progress of this state, it is at this point, it is how to use 1 minute, can be solved,

CodePudding user response:

refer to the second floor zara's reply:
child process operation will not be blocked, but sometimes it is more than the expected maximum execution time of 1 minute; I think I should attatch check on the progress of this state, it is at this point, it is how to use 1 minute, can be solved,

I don't like a timeout problems phenomenon, process in the list that far exceeds the time 1 minute (observation is the whole night in), the child has a written text operations, will probably write 50 m, according to zhao four teachers "if the driver's behavior is not good (probably because the hardware driver management appears strange behavior), you may need to take a long time to clear the outstanding I/O,", is likely to be "driver's behavior is not good, will continue to watch this phenomenon first repetition, thanks to zara and zhao4zhong1
  • Related