The Aim of this MR is to fix https://bugs.winehq.org/show_bug.cgi?id=10941
In a nutshell: - CUI app starts, and CRT inits its std streams from console, - app calls FreeConsole() then AllocConsole() and expects the CRT I/O functions to be able to output to newly created console.
It fails: - when run with wineconsole, as the inherited std consoles are closed in FreeConsole(). Added tests, but current implementation of kernelbase is correct. So, the fix is to force wineconsole to pass unbound console handles with standard inheritance (to they are not closed), - when run from unix console, the std handles were also closed. There's no unbound console in that case. The fix is not to close these handles in FreeConsole(). - the other cases from the bug entry work because cmd was created with unbound console handles.