mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
Bug 304096: Fix interrupting Cygwin gdb for both DSF-GDB and CDI-GDB. Send a real CTRL-C; don't use 'kill -SIGINT'
This commit is contained in:
parent
4aee96ae0b
commit
ea7d84d9f8
4 changed files with 27 additions and 7 deletions
|
@ -44,6 +44,7 @@ typedef struct _procInfo {
|
|||
HANDLE eventWait;
|
||||
HANDLE eventTerminate; // signaled when Spawner.terminate() is called; more forceful terminate request (SIGTERM signal in UNIX world)
|
||||
HANDLE eventKill; // signaled when Spawner.kill() is called; most forceful terminate request (SIGKILL signal in UNIX world)
|
||||
HANDLE eventCtrlc; // signaled when Spawner.interruptCTRLC() is called; like interrupt() but sends CTRL-C in all cases, even when inferior is a Cygwin program
|
||||
} procInfo_t, * pProcInfo_t;
|
||||
|
||||
static int procCounter = 0; // Number of running processes
|
||||
|
@ -75,6 +76,7 @@ typedef enum {
|
|||
SIG_INT,
|
||||
SIG_KILL = 9,
|
||||
SIG_TERM = 15,
|
||||
CTRLC = 1000 // special, Windows only. Sends CTRL-C in all cases, even when inferior is a Cygwin program
|
||||
} signals;
|
||||
|
||||
extern CRITICAL_SECTION cs;
|
||||
|
@ -148,6 +150,7 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
|
|||
wchar_t eventWaitName[20];
|
||||
wchar_t eventTerminateName[20];
|
||||
wchar_t eventKillName[20];
|
||||
wchar_t eventCtrlcName[20];
|
||||
#ifdef DEBUG_MONITOR
|
||||
wchar_t buffer[1000];
|
||||
#endif
|
||||
|
@ -220,13 +223,15 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_exec0
|
|||
swprintf(eventWaitName, L"SAWait%p", pCurProcInfo);
|
||||
swprintf(eventTerminateName, L"SATerm%p", pCurProcInfo);
|
||||
swprintf(eventKillName, L"SAKill%p", pCurProcInfo);
|
||||
swprintf(eventCtrlcName, L"SACtrlc%p", pCurProcInfo);
|
||||
|
||||
pCurProcInfo->eventBreak = CreateEventW(NULL, FALSE, FALSE, eventBreakName);
|
||||
pCurProcInfo->eventWait = CreateEventW(NULL, TRUE, FALSE, eventWaitName);
|
||||
pCurProcInfo->eventTerminate = CreateEventW(NULL, FALSE, FALSE, eventTerminateName);
|
||||
pCurProcInfo->eventKill = CreateEventW(NULL, FALSE, FALSE, eventKillName);
|
||||
pCurProcInfo->eventCtrlc = CreateEventW(NULL, FALSE, FALSE, eventCtrlcName);
|
||||
|
||||
swprintf(szCmdLine, L"\"%sstarter.exe\" %i %i %s %s %s %s ", path, pid, nLocalCounter, eventBreakName, eventWaitName, eventTerminateName, eventKillName);
|
||||
swprintf(szCmdLine, L"\"%sstarter.exe\" %i %i %s %s %s %s %s ", path, pid, nLocalCounter, eventBreakName, eventWaitName, eventTerminateName, eventKillName, eventCtrlcName);
|
||||
nPos = wcslen(szCmdLine);
|
||||
|
||||
// Prepare command line
|
||||
|
@ -699,6 +704,11 @@ JNIEXPORT jint JNICALL Java_org_eclipse_cdt_utils_spawner_Spawner_raise
|
|||
SetEvent(pCurProcInfo -> eventBreak);
|
||||
ret = (WaitForSingleObject(pCurProcInfo -> eventWait, 100) == WAIT_OBJECT_0);
|
||||
break;
|
||||
case CTRLC:
|
||||
ResetEvent(pCurProcInfo -> eventWait);
|
||||
SetEvent(pCurProcInfo -> eventCtrlc);
|
||||
ret = (WaitForSingleObject(pCurProcInfo -> eventWait, 100) == WAIT_OBJECT_0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -861,6 +871,12 @@ void cleanUpProcBlock(pProcInfo_t pCurProcInfo)
|
|||
pCurProcInfo -> eventKill = 0;
|
||||
}
|
||||
|
||||
if(0 != pCurProcInfo -> eventCtrlc)
|
||||
{
|
||||
CloseHandle(pCurProcInfo -> eventCtrlc);
|
||||
pCurProcInfo -> eventCtrlc = 0;
|
||||
}
|
||||
|
||||
pCurProcInfo -> pid = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002, 2007 QNX Software Systems and others.
|
||||
* Copyright (c) 2002, 2010 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -151,7 +151,7 @@ int main() {
|
|||
szCmdLine[0]= 0;
|
||||
int nPos = 0;
|
||||
|
||||
for(int i = 7; i < argc; ++i)
|
||||
for(int i = 8; i < argc; ++i)
|
||||
{
|
||||
int nCpyLen;
|
||||
int len= wcslen(argv[i]);
|
||||
|
@ -192,11 +192,13 @@ int main() {
|
|||
|
||||
BOOL exitProc = FALSE;
|
||||
HANDLE waitEvent = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[4]);
|
||||
HANDLE h[4];
|
||||
h[0] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[3]); // simulated SIGINT
|
||||
HANDLE h[5];
|
||||
h[0] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[3]); // simulated SIGINT (CTRL-C or Cygwin 'kill -SIGINT')
|
||||
// h[1] we reserve for the process handle
|
||||
h[2] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[5]); // simulated SIGTERM
|
||||
h[3] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[6]); // simulated SIGKILL
|
||||
h[4] = OpenEventW(EVENT_ALL_ACCESS, TRUE, argv[7]); // CTRL-C, in all cases
|
||||
|
||||
SetConsoleCtrlHandler(HandlerRoutine, TRUE);
|
||||
|
||||
int parentPid = wcstol(argv[1], NULL, 10);
|
||||
|
@ -308,15 +310,16 @@ int main() {
|
|||
{
|
||||
// Wait for the spawned-process to die or for the event
|
||||
// indicating that the processes should be forcibly killed.
|
||||
DWORD event = WaitForMultipleObjects(4, h, FALSE, INFINITE);
|
||||
DWORD event = WaitForMultipleObjects(5, h, FALSE, INFINITE);
|
||||
switch (event)
|
||||
{
|
||||
case WAIT_OBJECT_0 + 0: // SIGINT
|
||||
case WAIT_OBJECT_0 + 4: // CTRL-C
|
||||
#ifdef DEBUG_MONITOR
|
||||
swprintf(buffer, _T("starter (PID %i) received CTRL-C event\n"), currentPID);
|
||||
OutputDebugStringW(buffer);
|
||||
#endif
|
||||
if (isCygwin(h[1])) {
|
||||
if ((event == (WAIT_OBJECT_0 + 0)) && isCygwin(h[1])) {
|
||||
// Need to issue a kill command
|
||||
wchar_t kill[1024];
|
||||
swprintf(kill, L"kill -SIGINT %d", pi.dwProcessId);
|
||||
|
@ -410,6 +413,7 @@ int main() {
|
|||
CloseHandle(h[1]);
|
||||
CloseHandle(h[2]);
|
||||
CloseHandle(h[3]);
|
||||
CloseHandle(h[4]);
|
||||
|
||||
return(dwExitCode);
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Reference in a new issue