Fix Windows Terminal window staying open#223
Fix Windows Terminal window staying open#223davidnewhall merged 2 commits intoUnpackerr:mainfrom jon-sanders:patch-1
Conversation
Adding "-H=windowsgui" to the Makefile seems to correct the issue where Windows Terminal windows stay open after launch.
|
If the terminal is staying open, it means the application experienced a panic. Can you check your logs and console output for that please? https://github.com/davidnewhall/unpackerr/blob/25cb291f1c0949a402109d497424f9f845bc30b7/main.go#L16 |
|
The other situation this comes up in is when you switch your default terminal in Windows from cmd.exe to the new Windows Terminal. This new terminal does not provide the same APIs and Go applications are not able to hide the Windows that are created. I fought this behavior a long time with another user to no avail. Microsoft acknowledged the problem with their deprecation of specific API methods, and I'm really not sure where that went. Does it work now? I don't know (I'm not a Windows user). ref: microsoft/terminal#12570 |
|
This is to fix the issue you were discussing in the Discord. There is no error in the logs or console, but on launch a blank Windows Terminal window is launched. Closing this window closes unpackerr. Adding the above flag to the windows-specific build flags prevented the empty window from opening, and as far as I can tell unpackerr still functions as before. |
|
I discuss many issues in Discord. If you could link it, it may jog my memory. This is unfortunately not a change I can accept. What we need to do is figure out why hiding the terminal window doesn't work. |
|
Check out the workaround they found for nzbget. Can you try this and see if it works? nzbget/nzbget#792 (comment) |
|
This workaround does solve the issue, and the console window disappears after unpackerr starts. It does appear that the console is immediately hidden on launch, and only shown again in case of an error on startup. Would it make sense to add the windowsgui flag (this builds as a GUI binary and prevents the console appearing) and communicate the error with a Windows MessageBox directly? I have implemented this and could add it to the pull request. |
|
I'm not really following what you're proposing. I do not really want to remove the GUI window entirely. I've written a number of apps that have to support multiple OSes, including Windows, and I've had much better success leaving that flag off and hiding the window. This new Windows Terminal fiasco is going to require some changes to keep working I can see. I'd like to figure out how to hide it.
It's shown any time |
Adding "-H=windowsgui" to the Makefile seems to correct the issue where Windows Terminal windows stay open after launch.