TerminateProcess和死锁 [英] TerminateProcess and deadlocks

查看:368
本文介绍了TerminateProcess和死锁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否真的Windows中的TerminateProcess函数可能挂起,因为进程内的线程陷入了死锁?

Is it real that the TerminateProcess function in Windows could hang because the threads inside the process were stuck in a deadlock?

示例:进程A正在运行进程B控制,现在进程A进入死锁,进程B检测到并决定使用TerminateProcess终止进程A.

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.

能否成功杀死已暂停的进程A?

Would it be successful in killing the hung Process A?

推荐答案

是的,进程持有的所有内核对象都将被释放,包括锁。

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

TerminateProcess的主要问题是进程在事情上没有发言权:if it's保持任何全局状态(文件,共享内存等),那么你不能保证这些事情在进程终止后处于一致状态。

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.

这篇关于TerminateProcess和死锁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆