Browse Source

fix UseShellExecute problem

tags/2.3
clowwindy 10 years ago
parent
commit
59502c1984
2 changed files with 10 additions and 5 deletions
  1. +3
    -3
      shadowsocks-csharp/Controller/PolipoRunner.cs
  2. +7
    -2
      shadowsocks-csharp/Controller/ShadowsocksController.cs

+ 3
- 3
shadowsocks-csharp/Controller/PolipoRunner.cs View File

@@ -43,10 +43,10 @@ namespace Shadowsocks.Controller
_process.StartInfo.FileName = temppath + "/ss_polipo.exe";
_process.StartInfo.Arguments = "-c \"" + temppath + "/polipo.conf\"";
_process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
_process.StartInfo.UseShellExecute = false;
_process.StartInfo.UseShellExecute = true;
_process.StartInfo.CreateNoWindow = true;
_process.StartInfo.RedirectStandardOutput = true;
_process.StartInfo.RedirectStandardError = true;
//_process.StartInfo.RedirectStandardOutput = true;
//_process.StartInfo.RedirectStandardError = true;
_process.Start();
}
}


+ 7
- 2
shadowsocks-csharp/Controller/ShadowsocksController.cs View File

@@ -58,12 +58,19 @@ namespace Shadowsocks.Controller
// some logic in configuration updated the config when saving, we need to read it again
_config = Configuration.Load();
pacServer.Stop();
local.Stop();
// don't put polipoRunner.Start() before pacServer.Stop()
// or bind will fail when switching bind address from 0.0.0.0 to 127.0.0.1
// though UseShellExecute is set to true now
// http://stackoverflow.com/questions/10235093/socket-doesnt-close-after-application-exits-if-a-launched-process-is-open
polipoRunner.Stop();
polipoRunner.Start(_config);
local = new Local(_config);
local.Start();
pacServer.Start(_config);
if (ConfigChanged != null)
{
@@ -98,8 +105,6 @@ namespace Shadowsocks.Controller
{
_config.shareOverLan = enabled;
SaveConfig(_config);
pacServer.Stop();
pacServer.Start(_config);
if (ShareOverLANStatusChanged != null)
{
ShareOverLANStatusChanged(this, new EventArgs());


Loading…
Cancel
Save