在哪种情况下程序会以0x40010004代码退出? [英] In which cases does program exit with 0x40010004 code?

查看:1658
本文介绍了在哪种情况下程序会以0x40010004代码退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序旨在在Windows平台上运行。

My program is designed to run on Windows platform.

有时它会因错误而终止。我无法在安装它的每台计算机上调试它;因此,我向其添加了向量异常处理程序,该处理程序将一些有关异常的信息发送到服务器。有些 0xC0000005 例外;我已修复它,但程序仍然终止(我无法在PC上重现错误)。

Sometimes it terminates with error. I could not debug it on each computer where it is installed; so I added vectored exception handler to it which sends some information about exception to server. There were some 0xC0000005 exceptions; I fixed it, but program still terminates (I could not reproduce error on my PC).

我编写了另一个程序,该程序在主进程句柄上等待,并通过主进程终止时的进程退出代码。我查看了退出代码,其中大多数是 0x40010004 DBG_TERMINATE_PROCESS )。我知道当调试器附加到应用程序然后终止它时,将出现此退出代码。但是我确定没有调试器。

I wrote another program, which waits on main process handle, and sends report with process exit code when main process terminates. I looked at exit codes, and most of them were 0x40010004 (DBG_TERMINATE_PROCESS). I know that this exit code appears when debugger is attached to an application and then terminates it; but I am sure that there is no debugger.

因此...在其他情况下,可以使用 DBG_TERMINATE_PROCESS 退出代码?

So... In which other cases can process be terminated with DBG_TERMINATE_PROCESS exit code?

推荐答案

从理论上讲,它可以是任何东西,因为 TerminateProcess 具有退出代码参数。

On the theoretical side it could be anything, since TerminateProcess has an exit code parameter.

实际上,最有可能是由于系统关闭。 Windows关闭时,它将尝试正常退出正在运行的程序(有关此处)。如果他们拒绝退出,它们可能会被系统以退出代码 0x40010004 终止。例如,如果您有一个显示模式对话框的GUI程序,然后尝试关闭系统,则系统将提示您 xy.exe阻止了关闭。如果单击强制关闭,则该进程将被退出,退出代码为 0x40010004

On the practical side, it's most likely due to system shutdown. When Windows shuts down, it tries to exit running programs gracefully (more on that here). If they refuse to quit, they might be terminated by the system with the exit code 0x40010004. For example, if you have a GUI program that displays a modal dialog, and then you try to shut down the system, you will be prompted with a message that "xy.exe is preventing shutdown". If you click "Force shutdown", the process will be killed with exit code 0x40010004.

重现这一点,请注意,等待应用程序进程 HANDLE 的程序可能会在您的主应用程序之前 终止。

If you try to reproduce this, be aware that the program waiting on your application's process HANDLE might be terminated before your main app.

这篇关于在哪种情况下程序会以0x40010004代码退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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