Added some error checking, because s*** happens.

meow-7.2.2
Dave SIMmONs 2011-03-07 17:16:16 -08:00
parent 30a772c5f1
commit 9a9f813c2f
1 changed files with 32 additions and 9 deletions

View File

@ -301,23 +301,44 @@ void create_console()
// redirect unbuffered STDOUT to the console
l_std_handle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
fp = _fdopen( h_con_handle, "w" );
*stdout = *fp;
setvbuf( stdout, NULL, _IONBF, 0 );
if (h_con_handle == -1)
{
llwarns << "create_console() failed to open stdout handle" << llendl;
}
else
{
fp = _fdopen( h_con_handle, "w" );
*stdout = *fp;
setvbuf( stdout, NULL, _IONBF, 0 );
}
// redirect unbuffered STDIN to the console
l_std_handle = (long)GetStdHandle(STD_INPUT_HANDLE);
h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
fp = _fdopen( h_con_handle, "r" );
*stdin = *fp;
setvbuf( stdin, NULL, _IONBF, 0 );
if (h_con_handle == -1)
{
llwarns << "create_console() failed to open stdin handle" << llendl;
}
else
{
fp = _fdopen( h_con_handle, "r" );
*stdin = *fp;
setvbuf( stdin, NULL, _IONBF, 0 );
}
// redirect unbuffered STDERR to the console
l_std_handle = (long)GetStdHandle(STD_ERROR_HANDLE);
h_con_handle = _open_osfhandle(l_std_handle, _O_TEXT);
fp = _fdopen( h_con_handle, "w" );
*stderr = *fp;
setvbuf( stderr, NULL, _IONBF, 0 );
if (h_con_handle == -1)
{
llwarns << "create_console() failed to open stderr handle" << llendl;
}
else
{
fp = _fdopen( h_con_handle, "w" );
*stderr = *fp;
setvbuf( stderr, NULL, _IONBF, 0 );
}
}
LLAppViewerWin32::LLAppViewerWin32(const char* cmd_line) :
@ -363,8 +384,10 @@ bool LLAppViewerWin32::initLogging()
void LLAppViewerWin32::initConsole()
{
llinfos << "Test before create_console" << llendl;
// pop up debug console
create_console();
llinfos << "Test after create_console" << llendl;
return LLAppViewer::initConsole();
}