disabling and enabling console output

Alex AJ at gmail.com
Thu May 16 17:18:01 UTC 2019


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.


More information about the Digitalmars-d-learn mailing list