In a unittest sequence I’m testing if a data corruption error is caught or not (deliberately feeding corrupt data).
In order to treat a program crash (e.g. corrupt data + poor buffer management) as a regular fail-condition I run the program in a child process with CreateProcess. My problem is that if it crashes I get a crash report dialog from Windows and I have to close it for the test-sequence to carry on.
Is there any way of using CreateProcess so that I can swallow the crash report from Windows?
You cannot do this with CreateProcess(), the child program has to take care of it itself. Two basic ways:
__try/__exceptkeywords to catch and handle the SEH exceptionTry to do as little as possible in either case, you have no idea what state the program is in when it suffered the heart attack. Best thing to do is to SetEvent() a named event and have your main process terminate the process.