Multiple instances of ss_privoxy (#665)
* Use job object to manage polipo service's external processes. Signed-off-by: noisyfox <timemanager.rick@gmail.com> * Only kill those ss_privoxy.exe created by this ss instance. Signed-off-by: noisyfox <timemanager.rick@gmail.com> * Update README Signed-off-by: noisyfox <timemanager.rick@gmail.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
using System.Diagnostics;
|
||||
using System.Management;
|
||||
using System.Text;
|
||||
|
||||
namespace Shadowsocks.Util.ProcessManagement
|
||||
{
|
||||
static class ThreadUtil
|
||||
{
|
||||
|
||||
/*
|
||||
* See:
|
||||
* http://stackoverflow.com/questions/2633628/can-i-get-command-line-arguments-of-other-processes-from-net-c
|
||||
*/
|
||||
public static string GetCommandLine(this Process process)
|
||||
{
|
||||
var commandLine = new StringBuilder(process.MainModule.FileName);
|
||||
|
||||
commandLine.Append(" ");
|
||||
using (var searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id))
|
||||
{
|
||||
foreach (var @object in searcher.Get())
|
||||
{
|
||||
commandLine.Append(@object["CommandLine"]);
|
||||
commandLine.Append(" ");
|
||||
}
|
||||
}
|
||||
|
||||
return commandLine.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user