在 Windows 中真正杀死一个进程 [英] Really killing a process in Windows
问题描述
有时,Windows 机器上的程序会发疯并挂起.所以我会调用任务管理器并点击结束进程"按钮.然而,这并不总是有效.如果我尝试足够多次,它通常最终会死亡,但我真的希望能够立即杀死它.在 Linux 上,我可以 kill -9
来保证进程会终止.
Occasionally a program on a Windows machine goes crazy and just hangs. So I'll call up the task manager and hit the "End Process" button for it. However, this doesn't always work; if I try it enough times then it'll usually die eventually, but I'd really like to be able to just kill it immediately. On Linux I could just kill -9
to guarantee that a process will die.
这也可以用于编写批处理脚本,编写批处理脚本就是编程.
This also could be used for writing batch scripts and writing batch scripts is programming.
是否有一些 Windows 附带的程序或命令总是会终止进程?免费的第三方应用程序会很好,尽管我更喜欢能够在我第一次坐下的机器上做到这一点.
Is there some program or command that comes with Windows that will always kill a process? A free third-party app would be fine, although I'd prefer to be able to do this on machines I sit down at for the first time.
推荐答案
进程"选项卡上的结束进程"调用 TerminateProcess
,这是 Windows 知道的杀死进程的最终极方式.
"End Process" on the Processes-Tab calls TerminateProcess
which is the most ultimate way Windows knows to kill a process.
如果它没有消失,则它当前被锁定在等待某些内核资源(可能是有问题的驱动程序),并且您无法做任何事情(除非重新启动)才能使进程消失.
If it doesn't go away, it's currently locked waiting on some kernel resource (probably a buggy driver) and there is nothing (short of a reboot) you could do to make the process go away.
在以下时间查看此博客条目:http://blogs.technet.com/markrussinovich/archive/2005/08/17/unkillable-processes.aspx
Have a look at this blog-entry from wayback when: http://blogs.technet.com/markrussinovich/archive/2005/08/17/unkillable-processes.aspx
Linux 等基于 Unix 的系统也存在这样的问题:如果进程处于所谓的不间断睡眠"(由 top 和 ps 显示为状态 D),则进程可以在
),此时进程睡眠如此之好以至于它们无法处理传入的信号(这就是 kill -9
中存活kill
所做的 - 发送信号).
Unix based systems like Linux also have that problem where processes could survive a kill -9
if they are in what's known as "Uninterruptible sleep" (shown by top and ps as state D
) at which point the processes sleep so well that they can't process incoming signals (which is what kill
does - sending signals).
通常,不间断睡眠不会持续很长时间,但在 Windows 下,损坏的驱动程序或损坏的用户空间程序(vfork
没有 exec
)最终可能会在 中睡眠D
永远.
Normally, Uninterruptible sleep should not last long, but as under Windows, broken drivers or broken userpace programs (vfork
without exec
) can end up sleeping in D
forever.
这篇关于在 Windows 中真正杀死一个进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!