I have a windows (VS2013) c++ application. throughout the application I have calls to printf to output information. In order to better look through some of that information I wanted to try using findstr
on it. while debugging this I am unable to tell where the information is being output to. The application has multiple threads.
myApplication.exe > foo.txt 2>&1
# here is a bunch of stuff that is printed to the console when I don't think it should be.
will create an empty file named foo.txt with no output and the messages will be written to the console afterwards, this confuses me as I think the above command should pipe both stderr
and stdout
to the file foo.txt
. running type foo.txt
shows an empty file.
similarly I am unable to pipe the output to findstr
or similar or even tell where it is being output (it looks like normal stdout
)
running the command from a cygwin shell (which I tried as I assume there is some problem with stdout
or stderr
and the text is being piped to something else) does not show any output, which supports my idea that there may be a problem with that. where is the text being output to?
EDIT: it seems to have become relevant that I am using chromium embedded framework which, upon searching the code seems to have some stuff like:
// Add console so that 'logging' (really printf) is captured
// TODO: drop this once we no longer need it?
if(AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole()){
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
which seems pretty culpable, thanks to @frymode for pointing me in the right direction, I'll update with a solution once I've found one.