disabling and enabling console output

Alex AJ at gmail.com
Thu May 16 14:53:14 UTC 2019


I have some code that disables the console because some other 
code puts junk on it that I don't want to see... then I enable it.

stdout.close();
stderr.close();

...
stdout.open("CON", "w");
stderr.open("CON", "w");

It works but when the routine that uses this is called twice, it 
completely disables all output afterwards.

//1
stdout.close();
stderr.close();
//2
stdout.open("CON", "w");
stderr.open("CON", "w");
//3
stdout.close();
stderr.close();
//4
stdout.open("CON", "w");
stderr.open("CON", "w");
//5


So, one gets output at 1 and 3 but not 5.

Am I doing something wrong or is this a bug?


I've tried various things such as saving and restoring stdout, 
using CONOUT$, etc...

I think it might be outputting in 3 because of caching rather 
than it actually working once.

Can play around with it here:

https://run.dlang.io/is/q3kpSB


More information about the Digitalmars-d-learn mailing list