mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 01:42:30 +00:00
[CMD] Don't pass CTRL-C to child processes.
CORE-11677 The standard Win32 Console Control Handler will give CTRL-C events to processes spawned from cmd.exe. If cmd.exe calls GenerateConsolCtrlEvent() then the child process will receive two CTRL-C events.
This commit is contained in:
parent
94ead99e0c
commit
23de2099e0
|
@ -429,7 +429,7 @@ Execute(LPTSTR Full, LPTSTR First, LPTSTR Rest, PARSED_COMMAND *Cmd)
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
TRUE,
|
TRUE,
|
||||||
0, /* CREATE_NEW_PROCESS_GROUP */
|
0,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
&stui,
|
&stui,
|
||||||
|
@ -1459,26 +1459,16 @@ BOOL WINAPI BreakHandler(DWORD dwCtrlType)
|
||||||
{
|
{
|
||||||
DWORD dwWritten;
|
DWORD dwWritten;
|
||||||
INPUT_RECORD rec;
|
INPUT_RECORD rec;
|
||||||
static BOOL SelfGenerated = FALSE;
|
|
||||||
|
|
||||||
if ((dwCtrlType != CTRL_C_EVENT) &&
|
if ((dwCtrlType != CTRL_C_EVENT) &&
|
||||||
(dwCtrlType != CTRL_BREAK_EVENT))
|
(dwCtrlType != CTRL_BREAK_EVENT))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (SelfGenerated)
|
|
||||||
{
|
|
||||||
SelfGenerated = FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!TryEnterCriticalSection(&ChildProcessRunningLock))
|
if (!TryEnterCriticalSection(&ChildProcessRunningLock))
|
||||||
{
|
{
|
||||||
SelfGenerated = TRUE;
|
/* Child process is running and will have received the control event */
|
||||||
GenerateConsoleCtrlEvent (dwCtrlType, 0);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue