Allow opt-out of the named-pipe listener using an environment variable by daxian-dbw · Pull Request #26086 · PowerShell/PowerShell
PR Summary
Fix #11599
The named-pipe listener is created for all PowerShell instances today (including scenarios where apps host PowerShell). On Linux platforms, this causes the named pipe files left behind uncleaned when PowerShell terminates abruptly.
This PR includes changes to allow opt-out of the named-pipe listener using the environment variable POWERSHELL_DIAGNOSTICS_OPTOUT.
For reference, .NET has the environment variable DOTNET_EnableDiagnostics for disabling the debugger, the profiler, and EventPipe diagnostics (enabled by default).
PR Checklist
- PR has a meaningful title
- Use the present tense and imperative mood when describing your changes
- Summarized changes
- Make sure all
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header - This PR is ready to merge. If this PR is a work in progress, please open this as a Draft Pull Request and mark it as Ready to Review when it is ready to merge.
- Breaking changes
- None
- OR
- Experimental feature(s) needed
- Experimental feature name(s):
- User-facing changes
- Testing - New and feature
- N/A or can only be tested interactively
- OR
- Make sure you've added a new test if existing tests do not effectively test the code changed
daxian-dbw
added
the
CL-Engine
label
Sep 23, 2025|
|
||
| var boolStr = str.AsSpan(); | ||
|
|
||
| if (boolStr.Length == 1) |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you possibly use SequenceEqual possibly with or without StringComparer.OrdinalIgnoreCase to avoid the individual length and char checks. I assume .NET has all the necessary logic to make that performant and you could make this a lot simpler by doing something like
ReadOnlySpan<char> true1 = ['1']; ReadOnlySpan<char> trueYes = ['y', 'e', 's']; ReadOnlySpan<char> trueTrue = ['t', 'r', 'u', 'e']; // Repeat for false checks var boolStr = str.AsSpan() if (boolStr.SequenceEquals(true1, StringComparer.OrdinalIgnoreCase) || boolStr.SequenceEquals(trueYes, StringComparer.OrdinalIgnoreCase || ...) { return true; } // Repeat for false checks and default ...
Not sure if stackalloc'ing one big span with all the options and slicing it would be more efficient or not but that's probably in micro-optimising territory.
Edit: Ah I see this has been copied from elsewhere.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is copied from Telemetry.cs. I will keep it as is in this PR as this one will be included in the next preview and the following RC. But I will submit a separate PR to make this optimization change.
@iSazonov I guess you clicked the "Update branch" button. There were unrelated test failures after merging the master branch, so I have to revert that (force pushed the original 2 commits again). Please approve again once all CIs pass, thank you!
Oh, sorry! It seems the button is too near to scroll bar.
I restarted CIs and the WindowStyle test fail again. :-(
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
The failing tests are as following. They are not related to the changes and consistently fail for all CIs starting from 9/26.
I will merge the PR regardless of those 3 failures.
Describing WindowStyle argument
[-] -WindowStyle Normal should work on Windows
Expected exactly 'Normal', but got Hidden.
1044: $showCmd | Should -BeExactly $WindowStyle
at <ScriptBlock>, D:\a\PowerShell\PowerShell\test\powershell\Host\ConsoleHost.Tests.ps1: line 1044
[-] -WindowStyle Minimized should work on Windows
Expected exactly 'Minimized', but got Hidden.
1044: $showCmd | Should -BeExactly $WindowStyle
at <ScriptBlock>, D:\a\PowerShell\PowerShell\test\powershell\Host\ConsoleHost.Tests.ps1: line 1044
[-] -WindowStyle Maximized should work on Windows
Expected exactly 'Maximized', but got Hidden.
1044: $showCmd | Should -BeExactly $WindowStyle
at <ScriptBlock>, D:\a\PowerShell\PowerShell\test\powershell\Host\ConsoleHost.Tests.ps1: line 1044
[UPDATE] I cannot bypass the policy to merge the PR with failing tests. The 3 tests are disabled now in master branch, and I will rebase the PR against the master branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters