PowerShell does not correctly capture stdout from a windows app when redirecting to a file
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- powershell
- Domain
- cli, operating-systems
Research direction
Start with the reproduction in discussion 25875 and the example code in rhubarb-geek-nz/pipe-dream; compare t1.exe, t2.exe, and t3.exe using file redirection and Out-String -Stream on Windows. The payload names no PowerShell source file or test, so trace the output-redirection and child-process handling from the reproduction. Done means stdout from a Windows app is written completely to the redirected file rather than producing an empty file.
Written by the indexing model from the issue text.
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
https://github.com/PowerShell/PowerShell/discussions/25875
See example code at https://github.com/rhubarb-geek-nz/pipe-dream
t1 is a console app
t2 and t3 are window apps
All three write to stdout.
With PowerShell piping output from t1.exe to a file works.
With PowerShell redirecting output from t2.exe and t3.exe to a file creates an empty file.
The working assumption is that PowerShell creates a pipe for stdout and does the writing to the file itself rather than handing the file handle to the child.
Because the app is not a console app it does not wait for the process to finish.
However, because it should be reading from a pipe and writing to a file, when the process terminates is irrelevant, it should wait for the end of file on the pipe.
Using
.\t2.exe | Out-String -Stream
Does work as expected and shows that the stdout can be processed from a windows application.
Expected behavior
That redirecting output from a windows app will write all stdout content to a file.
Actual behavior
Redirection output from a windows app to a file creates an empty file
Error details
File contains zero bytes
Environment data
Name Value
---- -----
PSVersion 7.6.6
PSEdition Core
GitCommitId 7.6.6
OS Microsoft Windows 10.0.26200
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
- Dominant language
- C#
- Stars
- 56.1k
- Forks
- 8.5k
- Avg merge
- 12h 33m
- Merged PRs (30d)
- 73
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PowerShell/PowerShell
-
Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
PowerShell/PowerShell#28432 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
Needs-Investigation WG-Engine WG-NeedsReview
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
PowerShell/PowerShell#28283 · 1 comment ·
Maintainers usually reply within 1 day
-
Contributing tab on rendered Readme.md has broken links to two images, under .github/Images, but previews ok in .github/Contributing.mdPossibly taken @Soumilgit claimed this 22 days ago. OpenIssue-Enhancement Needs-Triage
Difficulty 1/5 1-3 hours Newbie friendliness 68/100
PowerShell/PowerShell#28256 · 1 comment ·
Maintainers usually reply within 1 day
-
Issue-Enhancement Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
PowerShell/PowerShell#28138 · 1 reaction ·
Maintainers usually reply within 1 day
-
Add support for WebRequestMethod QUERYPossibly taken @soroshsabz claimed this 52 days ago. OpenIssue-Enhancement Up-for-Grabs WG-Cmdlets WG-Reviewed
Difficulty 1/5 Under an hour Newbie friendliness 86/100
PowerShell/PowerShell#28061 · 4 comments · 3 reactions ·
Maintainers usually reply within 1 day
All issues in PowerShell/PowerShell
Similar issues
-
area-templates triage:bot-seen triage:needs-human
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
microsoft/aspire#22356 · 1 comment ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/aspire.dev#2184 ·
Maintainers usually reply within 2 days
-
area-controls-refreshview platform/ios s/triaged
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
dotnet/maui#40314 · 1 reaction ·
Maintainers usually reply within 1 day
-
Needs: Triage (Functions) v5 v5-preview5
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Azure/azure-functions-core-tools#5918 ·
Maintainers usually reply within 1 day
-
kind:ux needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
elsa-workflows/elsa-foundation#4712 · 1 comment ·
Maintainers usually reply within 1 day