[PR #2244] [MERGED] Prevent unwanted debug logs when calling _DoGetConsoleInput #24864

Open
opened 2026-01-31 09:05:49 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2244
Author: @j4james
Created: 8/5/2019
Status: Merged
Merged: 8/6/2019
Merged by: @undefined

Base: masterHead: fix-unwanted-debug-logs


📝 Commits (1)

  • 4e25c33 Don't log an error message when _DoGetConsoleInput returns CONSOLE_STATUS_WAIT.

📊 Changes

1 file changed (+48 additions, -28 deletions)

View changed files

📝 src/host/directio.cpp (+48 -28)

📄 Description

Summary of the Pull Request

The _DoGetConsoleInput method is documented as returning STATUS_SUCCESS if data was found, and CONSOLE_STATUS_WAIT if there wasn't enough data or it needed to block. While the latter is an expected response, the fact that its high bit is set means it is treated as an error, generating many unwanted logs in the debug output window. This PR makes sure that the CONSOLE_STATUS_WAIT response is never logged as an error.

PR Checklist

  • Closes Subset of Ligatures not working when using Powershell (#2075)
  • CLA signed. If not, go over here and sign the CLA
  • Tests added/passed
  • Requires documentation to be updated
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #2075

Detailed Description of the Pull Request / Additional comments

The _DoGetConsoleInput is called from four places in the ApiRoutines class. In each case, the NTSTATUS response is returned via the RETURN_NTSTATUS macro, which is what currently generates the debug logs. This PR simply adds a check before the RETURN_NTSTATUS call to handle the CONSOLE_STATUS_WAIT as a special case, and return it directly (using HRESULT_FROM_NT to convert the NTSTATUS to an HRESULT).

I considered using the RETURN_IF_FAILED_WITH_EXPECTED macro for this, but it expects an HRESULT rather than an NTSTATUS, which means first converting the status with wil::details::NtStatusToHr to match the existing behaviour, and also converting the CONSOLE_STATUS_WAIT in order to compare it as an HRESULT. In the end it's not really simpler than an extra comparison step, doesn't seem quite as clear, and doesn't exactly match the existing behaviour.

Validation Steps Performed

I ran the code from within the Visual Studio debugger and confirmed that it no longer generated a lot of debug logs when typing in a conhost WSL shell.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/2244 **Author:** [@j4james](https://github.com/j4james) **Created:** 8/5/2019 **Status:** ✅ Merged **Merged:** 8/6/2019 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `fix-unwanted-debug-logs` --- ### 📝 Commits (1) - [`4e25c33`](https://github.com/microsoft/terminal/commit/4e25c3373da7607a23f88b42a170ee8576309a00) Don't log an error message when _DoGetConsoleInput returns CONSOLE_STATUS_WAIT. ### 📊 Changes **1 file changed** (+48 additions, -28 deletions) <details> <summary>View changed files</summary> 📝 `src/host/directio.cpp` (+48 -28) </details> ### 📄 Description ## Summary of the Pull Request The `_DoGetConsoleInput` method is documented as returning `STATUS_SUCCESS` if data was found, and `CONSOLE_STATUS_WAIT` if there wasn't enough data or it needed to block. While the latter is an expected response, the fact that its high bit is set means it is treated as an error, generating many unwanted logs in the debug output window. This PR makes sure that the `CONSOLE_STATUS_WAIT` response is never logged as an error. ## PR Checklist * [x] Closes #2075 * [x] CLA signed. If not, go over [here](https://cla.opensource.microsoft.com/microsoft/Terminal) and sign the CLA * [ ] Tests added/passed * [ ] Requires documentation to be updated * [x] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #2075 ## Detailed Description of the Pull Request / Additional comments The `_DoGetConsoleInput` is called from four places in the `ApiRoutines` class. In each case, the `NTSTATUS` response is returned via the `RETURN_NTSTATUS` macro, which is what currently generates the debug logs. This PR simply adds a check before the `RETURN_NTSTATUS` call to handle the `CONSOLE_STATUS_WAIT` as a special case, and return it directly (using `HRESULT_FROM_NT` to convert the `NTSTATUS` to an `HRESULT`). I considered using the `RETURN_IF_FAILED_WITH_EXPECTED` macro for this, but it expects an `HRESULT` rather than an `NTSTATUS`, which means first converting the status with `wil::details::NtStatusToHr` to match the existing behaviour, and also converting the `CONSOLE_STATUS_WAIT` in order to compare it as an `HRESULT`. In the end it's not really simpler than an extra comparison step, doesn't seem quite as clear, and doesn't exactly match the existing behaviour. ## Validation Steps Performed I ran the code from within the Visual Studio debugger and confirmed that it no longer generated a lot of debug logs when typing in a conhost WSL shell. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:05:49 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#24864