On Thursday, 16 May 2019 at 17:07:39 UTC, Vladimir Panteleev
wrote:
On Thursday, 16 May 2019 at 17:05:01 UTC, Alex wrote:
One thing you could try is going one level lower, and using
dup() to save the stream to another fd, close() to close the
stdout one, and dup2() to restore the saved fd over the
stdout one.
Unfortunately D doesn't seem to have dup, dup2.
They are in the C library. Looks like Druntime has D
declarations only for Posix:
https://github.com/cybershadow/druntime/blob/issue19433/src/core/sys/posix/unistd.d#L51-L52
You can just copy those.
adding
int dup(int) @trusted;
int dup2(int, int) @trusted;
int close(int) @trusted;
int open(in char*, int, ...) @trusted;
results in an unresolved symbol.