Hello.
I have a problem sending a GenerateConsoleCtrlEvent() to a child process with a new
console. Doesn't matter if the CTRL_BREAK_EVENT or the CTRL_C_EVENT is sent, the process
just keeps running.
Here's the source of a test program:
int main()
{
BOOL rc;
STARTUPINFO si = { sizeof (STARTUPINFO) };
PROCESS_INFORMATION pi;
rc = CreateProcess(NULL, "loop.exe",
NULL, NULL, FALSE,
CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP,
NULL, NULL,
&si, &pi);
Sleep(2000);
rc = GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, pi.dwProcessId); WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
return 0;
}
loop.exe is a simple console program that outputs 10000 lines to the screen and
terminates.
Manually hitting Ctrl-Break on the console of loop.exe works OK.
Omitting the CREATE_NEW_CONSOLE flag from the CreateProcess() call works too but the
problem is that I *have* to use a separate console in the real app. Suggestions please.
Thanxalot!
Have fun,
Alex.
--
My email address is intentionally mangled to foil spambots.
Please remove the "---filter---" from the address for replying.
Sorry for the inconvenience.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 407 |
Nodes: | 16 (2 / 14) |
Uptime: | 15:28:49 |
Calls: | 8,555 |
Calls today: | 7 |
Files: | 13,219 |
Messages: | 5,925,665 |