Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cooked input cancellation on Windows #63

Open
alexrp opened this issue Dec 30, 2021 · 8 comments
Open

Support cooked input cancellation on Windows #63

alexrp opened this issue Dec 30, 2021 · 8 comments
Labels
area: drivers Issues related to the terminal drivers. os: windows Issues that are specific to Windows (10, 11, etc). state: blocked Issues that are blocked on some other issue/work. type: feature Issues that are classified as feature requests.
Milestone

Comments

@alexrp
Copy link
Sponsor Member

alexrp commented Dec 30, 2021

See discussion on #46 and #61, as well as commit adf2a45.

@alexrp alexrp added os: windows Issues that are specific to Windows (10, 11, etc). type: feature Issues that are classified as feature requests. state: blocked Issues that are blocked on some other issue/work. area: drivers Issues related to the terminal drivers. labels Dec 30, 2021
@alexrp alexrp added this to the v2.0 milestone Dec 30, 2021
@alexrp alexrp self-assigned this Dec 30, 2021
@alexrp
Copy link
Sponsor Member Author

alexrp commented Jan 16, 2022

Started a discussion: microsoft/terminal#12143

@alexrp alexrp modified the milestones: v2.0, v3.0 Oct 28, 2022
@alexrp alexrp modified the milestones: v3.0, Future Jan 1, 2024
@alexrp
Copy link
Sponsor Member Author

alexrp commented Jan 4, 2024

Proposed a whacky but potentially workable(?) hack for this here: microsoft/terminal#12143 (comment)

Thoughts on that approach very welcome. (cc @scottbilas @xoofx)

@scottbilas
Copy link
Contributor

I'm always in favor of an approach that works, even with caveats, over endless waiting for the gears to turn in a big software company. :) Seems like it's hard to get their attention on this.

@alexrp
Copy link
Sponsor Member Author

alexrp commented Jan 5, 2024

One aspect to consider is how this would work when standard I/O handles are redirected. Obviously, if we close redirected handles, we can't just simply reopen them again like we can with the console. We would need to special-case files, pipes, etc.

🤔

Looking at the .NET BCL, there's a whole bunch of code to handle cancellation in the FileStream backend code, both for the synchronous and asynchronous cases. So I'm now thinking this should be tied into #76 so we can make use of all the infrastructure that the .NET BCL already has in place for handling synchronous/asynchronous cancellation for those cases. Due to the Unix issue mentioned there, we could just do this work in the Windows terminal driver only, for now. (That's fine anyway, as the Unix terminal driver is quite clean in general, and UnixCancellationPipe has served us pretty well.)

@alexrp
Copy link
Sponsor Member Author

alexrp commented Jan 8, 2024

Sigh. Doesn't seem like that hack will work either.

  • Reading from GetStdHandle(STD_INPUT_HANDLE) and then closing that handle from another thread doesn't cause the read to get interrupted for some reason.
  • Reading from CreateFile("CONIN$", ...) and then closing that handle from another thread just causes CloseHandle() to block until the read completes.

I guess this might have worked on Windows 7, but Windows 8.1 completely changed how console handles work, so I figure that's why I had no luck here.

Sadness all around.

@alexrp
Copy link
Sponsor Member Author

alexrp commented Jan 8, 2024

Need to see if NtClose() will work, since CloseHandle() (apparently?) special-cases console handles.

@alexrp
Copy link
Sponsor Member Author

alexrp commented Jan 17, 2024

Ok, good news: It seems to work. (See the discussion on microsoft/terminal#12143 for context.)

If you can, please either clone the Git repo and try the cancellation sample, or consume the GitHub packages and see if it works that way. If there are no issues with it, I'll make a release soon-ish.

@alexrp alexrp removed the state: blocked Issues that are blocked on some other issue/work. label Jan 17, 2024
@alexrp alexrp modified the milestones: Future, v1.0 Jan 17, 2024
@alexrp
Copy link
Sponsor Member Author

alexrp commented Jan 17, 2024

Going to reopen because of this: microsoft/terminal#12143 (comment)

Still, we support cancellation of raw input now, so that's a lot better than nothing. This issue will track cancellation support for cooked input now.

@alexrp alexrp reopened this Jan 17, 2024
@alexrp alexrp modified the milestones: v1.0, Future Jan 17, 2024
@alexrp alexrp added the state: blocked Issues that are blocked on some other issue/work. label Jan 17, 2024
@alexrp alexrp changed the title Support input cancellation on Windows Support cooked input cancellation on Windows Jan 17, 2024
@alexrp alexrp removed their assignment Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: drivers Issues related to the terminal drivers. os: windows Issues that are specific to Windows (10, 11, etc). state: blocked Issues that are blocked on some other issue/work. type: feature Issues that are classified as feature requests.
Development

No branches or pull requests

2 participants