Fix infinite loop when ^D was pressed (MI)

llvm-svn: 233278
This commit is contained in:
Ilia K 2015-03-26 15:10:32 +00:00
parent 28074d6e9b
commit 5704347c29
1 changed files with 7 additions and 1 deletions

View File

@ -12,6 +12,7 @@
#include "MICmnStreamStdout.h"
#include "MICmnResources.h"
#include "MICmnLog.h"
#include "MIDriver.h"
#include "MIUtilSingletonHelper.h"
#include <string.h> // For std::strerror()
@ -205,7 +206,12 @@ CMICmnStreamStdin::ReadLine(CMIUtilString &vwErrMsg)
const MIchar *pText = ::fgets(&m_pCmdBuffer[0], m_constBufferSize, stdin);
if (pText == nullptr)
{
if (::ferror(stdin) != 0)
if (::feof(stdin))
{
const bool bForceExit = true;
CMIDriver::Instance().SetExitApplicationFlag(bForceExit);
}
else if (::ferror(stdin) != 0)
vwErrMsg = ::strerror(errno);
return nullptr;
}