Skip to content
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

Resolve -WindowStyle Hidden console flashing #10965

Closed
wants to merge 7 commits into from

Conversation

iSazonov
Copy link
Collaborator

@iSazonov iSazonov commented Nov 1, 2019

PR Summary

Fix #3028

PR Context

#10962 is direct implementation of pwshw idea. pwshw is only one option from many in the complex topic dicussed in #3028. The PR seems add more flexibility and allow to experiment with console, non-console, pseudo-console and GUI modes, allow to implement pwshw in the same way as we did for preview-pwsh, and also fix -WindowStyle Hidden scenario.

Update: I think follow work should be:

  • create xUnit tests for command line parser
  • refactor command line parser
    • make it static
    • move out execution code from parser (parser should only parse)
    • merge EarlyParser and parser

PR Checklist

@daxian-dbw
Copy link
Member

@iSazonov Please add description/context for this PR. Also, #10962 is also for fixing #3028, so what is the difference between your fix and that one?

@iSazonov
Copy link
Collaborator Author

iSazonov commented Nov 1, 2019

@daxian-dbw #10962 is direct implementation of pwshw idea. pwshw is only one option from many in the complex topic dicussed in #3028. The PR seems add more flexibility and allow to experiment with console, non-console, pseudo-console and GUI modes, allow to implement pwshw in the same way as we did for preview-pwsh, and also fix -WindowStyle Hidden scenario.

@daxian-dbw
Copy link
Member

You'd better add the PR description about what you are doing in this PR, so a reviewer would know.

@iSazonov
Copy link
Collaborator Author

iSazonov commented Nov 1, 2019

@daxian-dbw Already done.

Update: I think follow work should be:

  • create xUnit tests for command line parser
  • refactor command line parser
    • make it static
    • move out execution code from parser (parser should only parse)
    • merge EarlyParser and parser

@DHowett-MSFT
Copy link

Just so you’re aware, attaching to the parent process’s console as a Windows subsystem application (WinExe) will cause handle fighting where half your input will go to the parent and half to the child, and all output will be intermixed. This is because the parent, usually cmd or another instance of powershell will not wait for a spawned Windows subsystem application to exit.

You’ll probably see this:

C:\> pwsh
PowerShell 7.0.0
C:\> PS C:\>

(One prompt from CMD, one from powershell, both running and reading input simultaneously.)

This is impossible to work around without...

  1. A generic solution in the operating system
  2. A hack where powershell knows that it’s spawning another version of powershell, and waits for it to finish (working around the problem only for the PS->PS case.)

@DHowett-MSFT
Copy link

Attaching back to the parent’s console handle can also make the console fail to exit because a Windows subsystem application is still attached to it. This happens when you run code from cmd and then type in exit. CMD exits and the window remains because VSCode reattaches to its parent’s console handle.

@iSazonov
Copy link
Collaborator Author

@DHowett-MSFT Thanks! The scenario you describe is "Start-Process -NoNewWindow". We have an issue for it. I agree that we can not resolve it in simple way.
Original issue for the PR asks to address a scenario like scheduled task in user session so that user does not see PowerShell window. In the PR I try to demo how simple we can manually allocate a console to resolve the ask if no user IO is implied.

@ghost ghost added the Review - Needed The PR is being reviewed label May 27, 2020
@ghost
Copy link

ghost commented May 27, 2020

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Mainainer, Please provide feedback and/or mark it as Waiting on Author

@SteveL-MSFT SteveL-MSFT added this to the 7.2-Consider milestone Dec 9, 2020
@ghost ghost removed this from the 7.2-Consider milestone Dec 9, 2020
@ghost
Copy link

ghost commented Dec 9, 2020

Open PRs should not be assigned to milestone, so they are not assigned to the wrong milestone after they are merged. For backport consideration, use a backport label.

@ghost ghost added the Review - Needed The PR is being reviewed label Sep 23, 2021
@ghost
Copy link

ghost commented Sep 23, 2021

This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days.
Maintainer, please provide feedback and/or mark it as Waiting on Author

@iSazonov iSazonov closed this Apr 16, 2022
@iSazonov iSazonov deleted the noconsole-build branch April 16, 2022 19:11
@ghost ghost removed the Review - Needed The PR is being reviewed label Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Powershell -WindowStyle Hidden still shows a window briefly
7 participants