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

Avoid shim blocking when running a GUI app #5728

Closed
wants to merge 1 commit into from

Conversation

milnak
Copy link

@milnak milnak commented Nov 14, 2023

Description

Currently scoop shim will block when running a GUI app.

To repro this, do the following from a powershell console:

scoop install extras/notepad2-zufuliu
notepad2

The console will be blocked until notepad exits.

I have added an environment variable that can be set to override this behavior.

Motivation and Context

Relates to #1606

How Has This Been Tested?

Build shim, verified against notepad2 and console apps.

Checklist:

  • I have read the Contributing Guide.
  • I have ensured that I am targeting the develop branch.
  • I have updated the documentation accordingly.
  • I have updated the tests accordingly.
  • I have added an entry in the CHANGELOG.

@milnak
Copy link
Author

milnak commented Nov 14, 2023

looks like visual studio did some reformatting of the file. If you want me to undo those reformats, let me know and ill push a new iter.

@spider2048
Copy link
Contributor

spider2048 commented Nov 14, 2023

Using the develop branch (which had #5559 and #5684 merged recently) would solve the issue for every shim type.
So, this is implemented in the develop branch.

But, when a target application uses AttachConsole to obtain console handles, both the current develop branch and your's won't be able to. For instance,

$ scoop config shim scoopcs
$ scoop install alacritty
$ alacritty -V
<blank>
$ &(scoop which alacritty) -V
alacritty 0.12.3 (5efb069)

There is #5721 waiting for approval which would solve this issue.
Because of this, the process can't obtain the handles to console just by using AttachConsole, because the shim exits.

@milnak
Copy link
Author

milnak commented Nov 14, 2023

@spider2048 it looks like your changes handle this case and more, so this PR can likely be closed.

@niheaven niheaven closed this Mar 20, 2024
@amorphobia
Copy link
Contributor

amorphobia commented Apr 8, 2024

Since the fix is not released yet (will be in 0.4.0), I provide a workaround for current version (0.3.1).

Save following content as np2.ps1 in your $env:Path:

if ($args.Length -lt 1) {
    Start-Process -WindowStyle hidden notepad2.exe
} else {
    Start-Process -WindowStyle hidden notepad2.exe ($args -join ' ')
}

Just use np2 [file_path] from command line.

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.

None yet

4 participants