IridiumIO / CompactGUI

Transparently compress active games and programs using Windows 10/11 APIs
GNU General Public License v3.0
4.71k stars 223 forks source link

`NamedPipeServerStream` conflict when restarting as an administrator #414

Closed Eta0 closed 1 week ago

Eta0 commented 3 months ago

Since commit 07b56bf1f7338274ae27208094cccc2aa8aa7519 fixing #396, relaunching the application as an administrator from the in-app prompt can crash with System.IO.IOException: All pipe instances are busy.

This happens because the construction of the NamedPipeServerStream in Application.xaml.vb is implicitly unique, so the new process will error out if it attempts to create its own before the old process closes its original one.

I tried a hacky workaround of constructing the named pipe server with maxNumberOfServerInstances = 2 and that prevents the crash, but I figure the named pipe should probably be cleaned up before the application-wide mutex is released (and before the subprocess starts), instead, to prevent unexpectedly sharing it for a brief moment before shutdown.