From 616d5f3adee3d98a7fe4f37b8daf0018ec7027c2 Mon Sep 17 00:00:00 2001 From: Brandon Turner Date: Sat, 5 Nov 2005 22:13:59 +0000 Subject: [PATCH] Send Ctrl signals to child process correctly. We can now use CTRL+C to close programs in cmd! svn path=/trunk/; revision=19022 --- reactos/subsys/system/cmd/cmd.c | 34 +++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/reactos/subsys/system/cmd/cmd.c b/reactos/subsys/system/cmd/cmd.c index bc7c05efc54..d97f56d207a 100644 --- a/reactos/subsys/system/cmd/cmd.c +++ b/reactos/subsys/system/cmd/cmd.c @@ -469,11 +469,12 @@ Execute (LPTSTR Full, LPTSTR First, LPTSTR Rest) NULL, NULL, TRUE, - CREATE_NEW_PROCESS_GROUP, + 0, /* CREATE_NEW_PROCESS_GROUP */ NULL, NULL, &stui, &prci)) + { if (IsConsoleProcess(prci.hProcess)) { @@ -1295,12 +1296,12 @@ ProcessInput (BOOL bFlag) ReadCommand (readline, CMDLINE_LENGTH); ip = readline; bEchoThisLine = FALSE; - bIsBatch = FALSE; + bIsBatch = FALSE; } - else - { - bIsBatch = TRUE; - } + else + { + bIsBatch = TRUE; + } /* skip leading blanks */ while ( _istspace(*ip) ) @@ -1426,20 +1427,33 @@ ProcessInput (BOOL bFlag) BOOL WINAPI BreakHandler (DWORD dwCtrlType) { + static BOOL SelfGenerated = FALSE; + if ((dwCtrlType != CTRL_C_EVENT) && (dwCtrlType != CTRL_BREAK_EVENT)) + { return FALSE; - + } + else + { + if(SelfGenerated) + { + SelfGenerated = FALSE; + return TRUE; + } + } + if (bChildProcessRunning == TRUE) { - GenerateConsoleCtrlEvent (CTRL_C_EVENT, - dwChildProcessId); + SelfGenerated = TRUE; + GenerateConsoleCtrlEvent (dwCtrlType, 0); return TRUE; } + bCtrlBreak = TRUE; /* FIXME: Handle batch files */ - /* FIXME: Print "^C" */ + //ConOutPrintf(_T("^C")); return TRUE;