forked from OSchip/llvm-project
Improve handling of ctrl-c with MSVC.
Currently hitting Ctrl-C in Windows LLDB-MI just exits MI. But according to test_lldbmi_stopped_when_interrupt() in TestMiSignal.py Ctrl-C should send a SIGINT signal to the inferior. Patch adds this functionality to Windows so SIGINT is sent on Ctrl-C. Patch from EwanCrawford. Reviewed in http://reviews.llvm.org/D9248. llvm-svn: 235887
This commit is contained in:
parent
55bdeb7bc7
commit
398732979a
|
@ -7,6 +7,12 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// Third Party Headers
|
||||
#ifdef _MSC_VER
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
#include <string.h> // For std::strerror()
|
||||
|
||||
// In-house headers:
|
||||
#include "MICmnStreamStdin.h"
|
||||
#include "MICmnStreamStdout.h"
|
||||
|
@ -14,7 +20,6 @@
|
|||
#include "MICmnLog.h"
|
||||
#include "MIDriver.h"
|
||||
#include "MIUtilSingletonHelper.h"
|
||||
#include <string.h> // For std::strerror()
|
||||
|
||||
//++ ------------------------------------------------------------------------------------
|
||||
// Details: CMICmnStreamStdin constructor.
|
||||
|
@ -206,6 +211,13 @@ CMICmnStreamStdin::ReadLine(CMIUtilString &vwErrMsg)
|
|||
const MIchar *pText = ::fgets(&m_pCmdBuffer[0], m_constBufferSize, stdin);
|
||||
if (pText == nullptr)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
// Was Ctrl-C hit?
|
||||
// On Windows, Ctrl-C gives an ERROR_OPERATION_ABORTED as error on the command-line.
|
||||
// The end-of-file indicator is also set, so without this check we will exit next if statement.
|
||||
if (::GetLastError() == ERROR_OPERATION_ABORTED)
|
||||
return nullptr;
|
||||
#endif
|
||||
if (::feof(stdin))
|
||||
{
|
||||
const bool bForceExit = true;
|
||||
|
|
|
@ -23,7 +23,7 @@ BOOL WINAPI CtrlHandler(DWORD ctrlType)
|
|||
{
|
||||
if (_ctrlHandler != NULL)
|
||||
{
|
||||
_ctrlHandler(0);
|
||||
_ctrlHandler(SIGINT);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
|
|
Loading…
Reference in New Issue