Process cntl-c so that commands terminate and the prompt steps to a new line.
From: Jeff Latimer lats@yless4u.com.au
--- programs/cmd/batch.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c index 8bc3b5cb84b..82555a044a4 100644 --- a/programs/cmd/batch.c +++ b/programs/cmd/batch.c @@ -223,17 +223,32 @@ static WCHAR *WCMD_fgets_helper(WCHAR *buf, DWORD noChars, HANDLE h, UINT code_p DWORD charsRead; BOOL status; DWORD i; + DWORD conmode, oldconmode; + CONSOLE_READCONSOLE_CONTROL control; + + GetConsoleMode(h, &oldconmode); + conmode = oldconmode & ~ENABLE_PROCESSED_INPUT; + SetConsoleMode(h, conmode); + control.nLength = sizeof(CONSOLE_READCONSOLE_CONTROL); + control.nInitialChars = 0; + control.dwCtrlWakeupMask = 0x0008; + control.dwConsoleKeyState = 0;
/* We can't use the native f* functions because of the filename syntax differences between DOS and Unix. Also need to lose the LF (or CRLF) from the line. */
- if (VerifyConsoleIoHandle(h) && ReadConsoleW(h, buf, noChars, &charsRead, NULL) && charsRead) { + if (VerifyConsoleIoHandle(h) && ReadConsoleW(h, buf, noChars, &charsRead, &control) && charsRead) { + SetConsoleMode(h, oldconmode); if (!charsRead) return NULL;
/* Find first EOL */ for (i = 0; i < charsRead; i++) { if (buf[i] == '\n' || buf[i] == '\r') break; + if (buf[i] == 0x03) { + WCMD_output(L"^C\n"); + i = 0; + break;} } } else { @@ -241,6 +256,7 @@ static WCHAR *WCMD_fgets_helper(WCHAR *buf, DWORD noChars, HANDLE h, UINT code_p char *bufA; const char *p;
+ SetConsoleMode(h, oldconmode); bufA = xalloc(noChars);
/* Save current file position */
1) don't close and open new MR for the same change. That looses history of previous discussions. You just have to update the branch of your changes.
2) please take into account the comments made on the first MR. None has been taken into account (it may perhaps help you out in understanding while the tests are failing).
On Fri May 2 21:16:36 2025 +0000, eric pouech wrote:
- don't close and open new MR for the same change. That looses history
of previous discussions. You just have to update the branch of your changes. 2) please take into account the comments made on the first MR. None has been taken into account (it may perhaps help you out in understanding while the tests are failing).
Thanks Eric. My commit was 838 down the tree when a later commit invalided it. I couldn’t think of how to fix that without causing problems which led to my deleting it and the merge request.
As to the problems, I’ve been away and now I am back I’m still looking.
Regards Jeff Latimer