I have an application which happens to log to the console using winapi's WriteFile on a handle acquired from GetStdHandle. Minimal test case:
#include <Windows.h>
int main(int argc, char** argv) {
HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE);
if(GetFileType(console) == FILE_TYPE_UNKNOWN)
return;
WriteFile(console, "abc", 3, 0, 0);
}
built with default options in VS2013. This works without problems when invoked on a standard Windows console and when invoked from python2/python3/Sublime's console using e.g. subprocess.Popen('/path/to/my.exe')
.
Now I want to run this program as a build system in SublimeText 3. This is the build definition:
{
"cmd": [ "/path/to/my.exe" ]
}
According to documentation this should sort of be equivalent to using subprocess.Popen. However when I invoke this 'build system' Sublime's output pane displays abc
and then the call to WriteFile crashes with
0xC0000005: Access violation writing location 0x00000000.
What happens here? Is this a problem in my code, in Sublime, or in WriteFile? Anything that can be done about it? (I tried using shell_cmd
instead of cmd
but that makes no difference)