Set standard handles explicitly when starting a process with `-NoNewWindow` by daxian-dbw · Pull Request #25061 · PowerShell/PowerShell

Skip to content

Navigation Menu

Sign in

Appearance settings

Conversation

@daxian-dbw

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

jborean93

iSazonov

ltrzesniewski

SeeminglyScience

Choose a reason for hiding this comment

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

LGTM!

@daxian-dbw

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

@azure-pipelines

No pipelines are associated with this pull request.

@microsoft-github-policy-service

pwshBot pushed a commit to pwshBot/PowerShell that referenced this pull request

Apr 11, 2025

SIRMARGIN pushed a commit to SIRMARGIN/PowerShell that referenced this pull request

Dec 12, 2025

Labels