On Thu Feb 27 16:00:21 2025 +0000, Joe Souza wrote:
I'll answer #2 first: Under Windows, Ctrl-C definitely does break out of a DIR /P pause. Regarding the second part, I completely agree that the proper way to handle this would be to wait on both input and the Ctrl-C event. I have tried this. You may recall in an earlier iteration of my changes for a prior merge request, I left some code commented out which I then removed after you raised issue with it. This code was a call to WaitForMultipleObjects, waiting on both the input handle and the Ctrl-C event. The problem here which I believe I had stated at the time is that with Wine, the input handle is always signaled, even if there is no input waiting. The result was that the wait was always being satisfied immediately and DIR /P was not pausing at all. So that approach was abandoned in favor of what we have now. #1: This code here is based on the previous code for WCMD_Pause. That code was setting console mode flags to 0. I'm guessing that PAUSE has operated this way for many years. My changes use the new WCMD_wait_for_input for both PAUSE and DIR /P, and I did not want to break PAUSE behavior. Further, ENABLE_ECHO_INPUT is on by default, and counter to Microsoft's docs for SetConsoleMode, on Wine the character is echoed even if ENABLE_LINE_INPUT is disabled. The end result here is that DIR /P was echoing the character that the user pressed, whereas Windows does not exhibit that behavior. All that said, based on shortcomings in Wine that I discuss above, I believe that my changes here are currently the best approach.
the attached patch (on top of what you sent earlier on) should work as expected:
* the annoying parts: console handles don't support overlapped mode, and input console handles are signaled when there's a pending event... but a pending event could be mouse move, window resize, ctrl key down & up... maybe that's the reason you always check it as signaled * so the attached patch waits on both console input handle and control c event, but has to discriminate when the console input handle is signaled whether there's an actual character or some other things * it's still racy at some places, but given the API I don't see a clean way to do it * [wait-con.patch](/uploads/a537c394d4b98165b791a7979ad3f8ca/wait-con.patch)