Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
Windows 11 recently introduced a new virtual terminal to replace the Windows console. It behaves much more like standard Unix terminals:
Problems
--show-console
flag (and none of the CmdLine commands likelist
orinstall
), your console windows closes. This is not typical behavior for a command that you launch from a console and can be very surprising.Causes
Since ckan.exe is both a console application and a GUI application, Windows always automatically opens a console for it at launch. This is not desirable when running in GUI mode, so the GUI closes its console by finding it with
GetConsoleWindow
and then hiding it withShowWindow
.GetConsoleWindow
, so the whole approach breaks down anywayChanges
Now we use
FreeConsole
instead ofShowWindow
andGetConsoleWindow
. This API just detaches the current process from its console or terminal, so it won't aggressively close consoles that are still in use by other processes (such as a shell), but will auto-close any terminal that is only associated with ckan.exe. It is also supported by the new virtual terminals (see microsoft/terminal#14544), so console hiding should now work on Win11.Fixes #3902.