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.
Comment #1 by r.sagitario — 2018-09-29T13:43:39Z
Comment #2 by github-bugzilla — 2018-10-01T10:56:43Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/8f0aeedfc71c5036912c08660af1e77543a51e6a Fix issue 19275 - std.process: redirecting output in a non-console application fails MS runtime up to VS2013 used pseudo handle _NO_CONSOLE_FILENO in that case https://github.com/dlang/phobos/commit/a531a9ca97ca31104a30876ea08cbaa8f778959a Merge pull request #6722 from rainers/issue19275 Fix Issue 19275 - std.process: redirecting output in a non-console application fails merged-on-behalf-of: Nathan Sashihara <[email protected]>