Bug 19275 – std.process: redirecting output in a non-console application fails
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2018-09-29T13:37:46Z
Last change time
2018-10-01T10:56:44Z
Keywords
pull
Assigned to
No Owner
Creator
Rainer Schuetze
Comments
Comment #0 by r.sagitario — 2018-09-29T13:37:46Z
When linking a Windows application with the Microsoft runtime 12 or earlier, running a process and redirecting its output fails:
import std.process;
import core.sys.windows.windows;
extern(C) int main(string[] args)
{
try
{
auto res = execute(["dmd.exe", "--version"], null, Config.suppressConsole);
MessageBoxA(null, res.output.ptr, "OK", MB_OK);
}
catch(Throwable e)
{
MessageBoxA(null, e.msg.ptr, "EXCEPTION", MB_OK);
}
return 0;
}
alias extern(C) int function(string[] args) MainFunc;
extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc);
extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
return _d_run_main(0, null, &main); // arguments unused, retrieved via CommandLineToArgvW
}
causes an exception when built with `dmd -m64 redir.d -L/Subsystem:windows user32.lib` against VS2013. Works with -m32 or VS2015 and VS2017.