Is it possible for any windows console app to output to console, while not outputting to stdout nor stderr? If yes - how to capture/redirect the output?
I have a third party console app that I used to start from my C# app and redirect its stdandard error and output and read them from within my app. With an upgrade of this 3rd party app this approach stopped working. During investigation I found out that while it outputs to console; redirecting stderr to file caused it not to output to console (expected), but file was empty (very unexpected):
CNTK.exe 1>out.txt 2>err.txt
No content in out.txt nor err.txt
Without redirection the app outputs the basic diagnostic info into the console.
Based on the source code it uses fprintf(stderr, ...) for outputing - so I'm quite puzzled why it's not redirectable. Even regardless of the app in question or how it outputs to console - I'm quite puzzled how it is even possible for the app to output to console without user ability to redirect the output to pipes.
Edit: seems to be caused by a bug in older version of MS cpp runtime: https://connect.microsoft.com/VisualStudio/feedback/details/1441507/stdout-and-stderr-not-always-flushed-upon-process-exit 3rd party app is linked against VS 2013 runtime and codepath executed by my test was not explicitly calling fflush(stderr); prior exiting (despite this should not be needed, but it is due to the bug)