Skip to content

Set standard handles explicitly when starting a process with -NoNewWindow #25061

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

Merged
merged 4 commits into from
Mar 4, 2025

Conversation

daxian-dbw
Copy link
Member

PR Summary

Fix #24986

This is a follow-up fix to the changes introduced by #20853.

  • If we are starting a process with a new window, we should leave the standard handles unset when they are not redirected and let Windows figure out the default to use creating the process. Otherwise, the standard input of the new window will be tied with the old window for some reason and causes the new window to be unusable.
  • If we are starting a process re-using the current window (with -NoNewWindow), then we need to explicitly set all the standard handles, especially when any of them is redirected. Otherwise, the un-redirected handles will become invalid.

PR Checklist

@daxian-dbw daxian-dbw added CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log BackPort-7.5.x-Consider labels Feb 20, 2025
Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@daxian-dbw
Copy link
Member Author

/azp run PowerShell-CI-linux-packaging PowerShell-Windows-Packaging-CI

Copy link

No pipelines are associated with this pull request.

@daxian-dbw daxian-dbw merged commit 6e428a8 into PowerShell:master Mar 4, 2025
32 checks passed
@daxian-dbw daxian-dbw deleted the process branch March 4, 2025 00:17
Copy link
Contributor

microsoft-github-policy-service bot commented Mar 4, 2025

📣 Hey @daxian-dbw, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backport-7.5.x-Migrated CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log
Projects
Development

Successfully merging this pull request may close these issues.

Start-Process in 7.5.0: invalid handles, no output emitted on Windows
6 participants