开发者

TerminateProcess and deadlocks

开发者 https://www.devze.com 2023-01-01 13:40 出处:网络
Is it real that the TerminateProcess function in Windows cou开发者_如何学Pythonld hang because the threads inside the process were stuck in a deadlock?

Is it real that the TerminateProcess function in Windows cou开发者_如何学Pythonld hang because the threads inside the process were stuck in a deadlock?

Example: Process A is running under Process B's control, now Process A gets into a deadlock and Process B detects this and decides to 'Kill' process A using TerminateProcess.

Would it be successful in killing the hung Process A?


Yes, all kernel objects held by the process will be released, including locks.

The main problem with TerminateProcess is that the process has no say in the matter: if it's holding on to any global state (files, shared memory, etc) then you have no guarantee those things are in a consistent state after the process is terminated.


Yes. So long as you have the right permissions, TerminateProcess will kill the other process dead, regardless of how well hung it is.


TerminateProcess will kill each thread (as if TerminateThread had been used on each and every thread in the process).

But it won't kill threads that are stuck in the kernel (e.g. due to device driver bug).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号