I'm trying to write a test suite for a compiler (LLVM) and it works perfectly fine on every platform except for Windows. On Windows I get the "critical-error-handler" message box which stops the tests indefinitely.
This problem makes it very difficult to test because, with compilers, a problem often means invalid code on the assembly level, and thus crazy, unpredictable errors.
I found http://stackoverflow.com/questions/977275/during-a-subprocess-call-catch-critical-windows-errors-in-python-instead-of-lett while searching for the answer, but this doesn't work for me. I still get the message boxes when testing.
The documentation on [SetErrorMode](http://msdn.microsoft.com/en-us/library/ms680621(VS100).aspx) Says that:
SEM_FAILCRITICALERRORS:
The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling process.SEM_NOGPFAULTERRORBOX:
The system does not display the Windows Error Reporting dialog.Each process has an associated error mode that indicates to the system how the application is going to respond to serious errors. A child process inherits the error mode of its parent process.
However, after calling SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX)
and launching the process with CreateProcess
with dwCreationFlags = CREATE_NEW_CONSOLE
, I still get the boxes when subprocesses fail.
In case it matters, the exact Python code I am using is:
import ctypes
# 3 is SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX
ctypes.windll.kernel32.SetErrorMode(3)
How do I fix it?