In which cases does program exit with 0x40010004 code?

本小妞迷上赌 提交于 2019-12-12 08:26:31

问题


My program is designed to run on Windows platform.

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).

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.

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


回答1:


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

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.

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.



来源:https://stackoverflow.com/questions/37078953/in-which-cases-does-program-exit-with-0x40010004-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!