- May
- 13,117
- 180
For quite a while I've had a GENBREAK command in my 4CONSOLE plugin. It was quite simple:
I noticed that if TCC is waiting for input (e.g., at a command or "/P" prompt) such an artificially generated signal isn't seen until there's a keystroke. [I tested this with "LATER /s=2 GENBREAK" ... LATER another plugin function.]
I'm curious why.
I can get get the signal seen immediately if I use:
That seems particularly inelegant. Is there a better way?
Thanks.
Code:
INT WINAPI GENBREAK ( WCHAR * pArgs) {
if ( stristr(pArgs, L"/?") ) Printf(L"Generate a CTRL_C_EVENT\r\n");
else
{
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
}
return 0;
}
I'm curious why.
I can get get the signal seen immediately if I use:
Code:
INT WINAPI GENBREAK ( WCHAR * pArgs) {
if ( stristr(pArgs, L"/?") ) Printf(L"Generate a CTRL_C_EVENT\r\n");
else
{
PostMessage(g.hWndConsole, WM_CHAR, 0, 0);
GenerateConsoleCtrlEvent(CTRL_C_EVENT, 0);
PostMessage(g.hWndConsole, WM_CHAR, 0, 0);
}
return 0;
}
Thanks.